Hazelcast入门指南第3部分

这是从初学者的角度来看一系列有关如何使用Hazelcast的文章的延续。 如果您还没有阅读最后两个,我鼓励您阅读它们:

  • Hazelcast入门指南第1部分
  • Hazelcast入门指南第2部分



原始人来了

在上一篇文章中,我提到将ILock与IList和ISet一起使用,因为它们不是线程安全的。 令我惊讶的是,我没有涵盖Hazelcast的基本部分,即分布式原语。 他们解决了以分布式方式同步资源使用的问题。 那些执行大量线程编程的人将立即识别它们。 对于那些不熟悉线程编程的人,我将解释每个原语的作用并举一个例子。

长寿

这是一个分布式原子长。 这意味着所有操作都一次发生。 例如,可以在一个操作中添加一个数字并检索结果值。 可以获取值,然后添加值。 对于在此原语上执行的每项操作都是如此。 可以想象,它是线程安全的,但不能做到这一点,而且是线程安全的。

atomicLong.addAndGet(2 * atomicLong.get());

上面的行创建了一个竞争条件,因为有三个操作,读取原子long的内容,乘以2并将其添加到实例中。 仅在保证一步操作的情况下,线程才安全地存在。 为此,IAtomicLong有一个名为alterAndGet的方法。 AlterAndGet带有IFunction对象。 这使多步操作成为一步。 IAtomicLong始终只有一个同步备份,并且它是不可配置的。

IdGenerator

IAtomicLongs非常适合用来跟踪一个人有多少。 问题在于,由于呼叫很可能是远程呼叫,因此在某些情况下,IAtomicLongs并不是理想的解决方案。 这些情况之一就是生成唯一的ID。 IdGenerator就是为此目的而制作的。 它的工作方式是每个成员都要求生成一百万个ID。 一旦所有这些要求的数字都被使用,该部门将要求另外一百万。 因此,由于每个成员都有100万个ID,所以远程调用IdGenerator的机会是100万分之一。 这使得生成唯一ID的方法非常快捷。 如果发生任何重复,可能是因为成员没有加入。 如果成员在其段用尽之前发生故障,则ID中将存在间隙。 对于唯一的ID生成,缺少数字不是问题。 我确实认为成员没有挂接到集群是一个问题,但是如果发生这种情况,则有更大的事情要担心。 如果群集重新启动,则ID将从零再次开始。 那是因为id不能持久存在。 这是一个内存数据库,一个机会。 为了解决这个问题,可以将IdGenerators设置为以特定数字开头,只要其他人没有声明它并且还没有生成ID。 替代方法是创建一个自己的ID生成器或使用java.util.UUID类。 这可能需要更多的空间,但是每个项目都有自己的要求可以满足。 IdGenerator始终具有一个同步备份,无法进行配置。

这是经典的同步方法。 它是分发的排他锁。 只需调用方法锁,线程便会等待或获得锁。 一旦建立了锁定,就可以执行关键部分。 工作完成后,将使用解锁方法。 这项技术的资深人士会将关键部分放在try finally块中,在try块外部建立锁定,并在finally部分建立解锁。 这对于在线程安全的结构上执行操作非常有用。 获取锁的进程拥有锁,并且需要调用该锁才能使其他进程能够建立锁。 当一个人在网络上的多个位置都有线程时,这可能会出现问题。 Hazelcast想到了这个问题,并在成员退出时释放了锁定。 另一个功能是锁定方法的超时时间为300秒。 这样可以防止线程不足。 ILock具有一个同步备份,并且不可配置。

有经验的人的一些建议,使关键部分尽可能 ; 这有助于提高性能并防止死锁。 由于线程的执行顺序未知,因此死锁很难调试且难以测试。 漏洞一度表现出来,然后就没有。 由于锁放错了位置,因此可能会持续一周或更长时间。 然后必须确保它不会再次发生。 由于线程的执行未知,很难证明这一点。 等到一切完成时,老板会因为花费的时间而感到沮丧,并且不知道该错误是否已修复。

ICondition

是否曾经想等待事件发生,但又不想其他人也必须等待事件发生? 这正是线程编程中的条件。 在Java 1.5之前,这是通过synced-wait-notify技术完成的。 这可以通过锁定条件技术来执行。 和我一起旅行,我可以向大家展示这是如何工作的。 想象一下这样一种情况,其中存在一个非线程安全列表,并且有生产者和使用者编写和读取该清单。 显然,有一些关键部分需要保护。 那落入了锁。 建立锁定后,便可以开始关键工作。 唯一的问题是资源处于对线程无用的状态。 例如,使用者无法从空列表中提取条目。 生产者无法将条目放入完整列表。 这是条件进入的地方。生产者或消费者将进入while循环,以测试条件是否有利,然后调用condition.await()。 调用await之后,线程将放弃其锁定,并让其他线程访问其关键部分。 等待中的线程将重新获得锁以对其条件进行测试,并且可以等待更多时间或条件得到满足并开始执行工作。 关键部分完成后,线程可以调用signal()或signalAll()来告诉其他线程唤醒并检查其条件。 条件是由而不是Hazelcast实例创建的。 另一件事是,如果要分发条件,则必须使用lock.newCondition(String name)方法。 IConditions具有一个同步备份,无法配置。

我无法说出使用这种技术会发生多少死锁。 有时,当线程正在等待并且一切正常时,就会发出信号。 另一方面是在线程等待时发送信号,进入等待状态并永远等待。 出于这个原因,我主张在等待时使用超时,以便线程可以每隔一段时间检查一次是否满足条件。 这样,如果信号丢失,则可能发生的最坏情况是等待时间短而不是永远等待。 我在示例中使用了超时技术。 复制并粘贴所需的代码。 我宁愿使用正在使用的测试技术,也不愿使用未经测试的代码入侵互联网。

ICountDownLatch

ICountDownLatch是一个同步工具,当其计数器变为零时触发。 这不是进行协调的常用方法,但是在需要时可用。 我认为示例部分提供了有关其工作原理的更好的解释。 锁存器归零后可以复位,因此可以再次使用。 如果拥有成员离开,则会发出所有等待闩锁到达零的线程的信号,就好像已达到零。 ICountDownLatch在另一个地方同步备份,无法配置。

等量线

是的,有经典信号量的分布式版本。 这让我很兴奋,因为上次我上操作系统课时,信号灯需要一点硬件支持。 也许我只是和自己约会,哦,它仍然很酷(再次与自己约会)。 信号量通过限制可以访问资源的线程数来工作。 与锁不同,信号量没有所有权感,因此不同的线程可以释放对资源的声明。 与其余的原语不同,可以配置ISemaphore。 我在示例中配置一个。 它位于我项目的默认包中的hazelcast.xml中。

例子

这里是例子。 我对上一篇帖子发表了评论,要求我对代码进行缩进,以使其更具可读性。 由于我要发布的代码量很大,所以我这次肯定会这样做。 将会看到我以前没有讨论过的几件事。 一种是IExecutorService。 这是ExecutorService的分布式版本。 一个人实际上可以发送工作,以由不同的成员完成。 另一件事是,所有定义的Runnable / Callable类都实现了Serializable。 这在分布式环境中是必需的,因为可以将对象发送给不同的成员。 最后一件事是HazelcastInstanceAware接口。 它允许类访问本地 Hazelcast实例。 然后,类可以获取所需资源的实例(例如ILists)。 事不宜迟,我们开始。

长寿

package hazelcastprimitives.iatomiclong;import com.hazelcast.core.Hazelcast;
import com.hazelcast.core.HazelcastInstance;
import com.hazelcast.core.IAtomicLong;
import com.hazelcast.core.IFunction;
import java.io.Serializable;/**** @author Daryl*/
public class IAtomicLongExample {public static class MultiplyByTwoAndSubtractOne implements IFunction, Serializable {@Overridepublic Long apply(Long t) {return (long)(2 * t - 1);}}public static final void main(String[] args) {HazelcastInstance instance = Hazelcast.newHazelcastInstance();final String NAME = "atomic";IAtomicLong aLong = instance.getAtomicLong(NAME);IAtomicLong bLong = instance.getAtomicLong(NAME);aLong.getAndSet(1L);System.out.println("bLong is now: " + bLong.getAndAdd(2));System.out.println("aLong is now: " + aLong.getAndAdd(0L));MultiplyByTwoAndSubtractOne alter = new MultiplyByTwoAndSubtractOne();aLong.alter(alter);System.out.println("bLong is now: " + bLong.getAndAdd(0L));bLong.alter(alter);System.out.println("aLong is now: " + aLong.getAndAdd(0L));System.exit(0);}
}

注意,即使MutilpyAndSubtractOne类也实现了Serializable。

IdGenerator

package hazelcastprimitives.idgenerator;import com.hazelcast.core.Hazelcast;
import com.hazelcast.core.HazelcastInstance;
import com.hazelcast.core.IdGenerator;/**** @author Daryl*/
public class IdGeneratorExample {public static void main(String[] args) {HazelcastInstance instance = Hazelcast.newHazelcastInstance();IdGenerator generator = instance.getIdGenerator("generator");for(int i = 0; i < 10; i++) {System.out.println("The generated value is " + generator.newId());}instance.shutdown();System.exit(0);}
}

此ILock示例也可以视为ICondition示例。 我必须使用一个条件,因为ListConsumer始终在ListProducer之前运行,所以我让ListConsumer等到IList有消耗的东西。

package hazelcastprimitives.ilock;import com.hazelcast.core.Hazelcast;
import com.hazelcast.core.HazelcastInstance;
import com.hazelcast.core.HazelcastInstanceAware;
import com.hazelcast.core.ICondition;
import com.hazelcast.core.IExecutorService;
import com.hazelcast.core.IList;
import com.hazelcast.core.ILock;
import java.io.Serializable;
import java.util.concurrent.TimeUnit;/**** @author Daryl*/
public class ILockExample {static final String LIST_NAME = "to be locked";static final String LOCK_NAME = "to lock with";static final String CONDITION_NAME = "to signal with";/*** @param args the command line arguments*/public static void main(String[] args) {HazelcastInstance instance = Hazelcast.newHazelcastInstance();IExecutorService service = instance.getExecutorService("service");ListConsumer consumer = new ListConsumer();ListProducer producer = new ListProducer();try {service.submit(producer);service.submit(consumer);Thread.sleep(10000);} catch(InterruptedException ie){System.out.println("Got interrupted");} finally {instance.shutdown();}}public static class ListConsumer implements Runnable, Serializable, HazelcastInstanceAware {private transient HazelcastInstance instance;@Overridepublic void run() {ILock lock = instance.getLock(LOCK_NAME);ICondition condition = lock.newCondition(CONDITION_NAME);IList list = instance.getList(LIST_NAME);lock.lock();try {while(list.isEmpty()) {condition.await(2, TimeUnit.SECONDS);}while(!list.isEmpty()) {System.out.println("value is " + list.get(0));list.remove(0);}} catch(InterruptedException ie) {System.out.println("Consumer got interrupted");} finally {lock.unlock();}System.out.println("Consumer leaving");}@Overridepublic void setHazelcastInstance(HazelcastInstance hazelcastInstance) {instance = hazelcastInstance;}}public static class ListProducer implements Runnable, Serializable, HazelcastInstanceAware {private transient HazelcastInstance instance;@Overridepublic void run() {ILock lock = instance.getLock(LOCK_NAME);ICondition condition = lock.newCondition(CONDITION_NAME);IList list = instance.getList(LIST_NAME);lock.lock();try {for(int i = 1; i <= 10; i++){list.add(i);}condition.signalAll();} finally {lock.unlock();}System.out.println("Producer leaving");}@Overridepublic void setHazelcastInstance(HazelcastInstance hazelcastInstance) {instance = hazelcastInstance;}}
}

ICondition

这是真正的ICondition示例。 请注意,SpunProducer和SpunConsumer如何共享相同的ICondition并相互发出信号。 注意我正在使用超时来防止死锁。

package hazelcastprimitives.icondition;import com.hazelcast.core.Hazelcast;
import com.hazelcast.core.HazelcastInstance;
import com.hazelcast.core.HazelcastInstanceAware;
import com.hazelcast.core.ICondition;
import com.hazelcast.core.IExecutorService;
import com.hazelcast.core.IList;
import com.hazelcast.core.ILock;
import java.io.Serializable;
import java.util.concurrent.TimeUnit;/**** @author Daryl*/
public class IConditionExample {static final String LOCK_NAME = "lock";static final String CONDITION_NAME = "condition";static final String SERVICE_NAME = "spinderella";static final String LIST_NAME = "list";public static final void main(String[] args) {HazelcastInstance instance = Hazelcast.newHazelcastInstance();IExecutorService service  = instance.getExecutorService(SERVICE_NAME);service.execute(new SpunConsumer());service.execute(new SpunProducer());try {Thread.sleep(10000);} catch(InterruptedException ie) {System.out.println("Hey we got out sooner than I expected");} finally {instance.shutdown();System.exit(0);}}public static class SpunProducer implements Serializable, Runnable, HazelcastInstanceAware {private transient HazelcastInstance instance;private long counter = 0;@Overridepublic void run() {ILock lock = instance.getLock(LOCK_NAME);ICondition condition = lock.newCondition(CONDITION_NAME);IList list = instance.getList(LIST_NAME);lock.lock();            try {if(list.isEmpty()) {populate(list);System.out.println("telling the consumers");condition.signalAll();}for(int i = 0; i < 2; i++) {while(!list.isEmpty()) {System.out.println("Waiting for the list to be empty");System.out.println("list size: " + list.size() );condition.await(2, TimeUnit.SECONDS);}  populate(list);System.out.println("Telling the consumers");condition.signalAll();}} catch(InterruptedException ie) {System.out.println("We have a found an interuption");} finally {condition.signalAll();System.out.println("Producer exiting stage left");lock.unlock();}}@Overridepublic void setHazelcastInstance(HazelcastInstance hazelcastInstance) {instance = hazelcastInstance;}private void populate(IList list) {System.out.println("Populating list");long currentCounter = counter;for(; counter < currentCounter + 10; counter++) {list.add(counter);}}}public static class SpunConsumer implements Serializable, Runnable, HazelcastInstanceAware {private transient HazelcastInstance instance;@Overridepublic void run() {ILock lock = instance.getLock(LOCK_NAME);ICondition condition = lock.newCondition(CONDITION_NAME);IList list = instance.getList(LIST_NAME);lock.lock();            try {for(int i = 0; i < 3; i++) {while(list.isEmpty()) {System.out.println("Waiting for the list to be filled");condition.await(1, TimeUnit.SECONDS);}System.out.println("removing values");while(!list.isEmpty()){System.out.println("value is " + list.get(0));list.remove(0);}System.out.println("Signaling the producer");condition.signalAll();}} catch(InterruptedException ie) {System.out.println("We had an interrupt");} finally {System.out.println("Consumer exiting stage right");condition.signalAll();lock.unlock();}}@Overridepublic void setHazelcastInstance(HazelcastInstance hazelcastInstance) {instance = hazelcastInstance;}}}

ICountDownLatch

package hazelcastprimitives.icountdownlatch;import com.hazelcast.core.Hazelcast;
import com.hazelcast.core.HazelcastInstance;
import com.hazelcast.core.HazelcastInstanceAware;
import com.hazelcast.core.ICountDownLatch;
import com.hazelcast.core.IExecutorService;
import com.hazelcast.core.IList;
import com.hazelcast.core.ILock;
import java.io.Serializable;
import java.util.concurrent.TimeUnit;/**** @author Daryl*/
public class ICountDownLatchExample {static final String LOCK_NAME = "lock";static final String LATCH_NAME = "condition";static final String SERVICE_NAME = "spinderella";static final String LIST_NAME = "list";public static final void main(String[] args) {HazelcastInstance instance = Hazelcast.newHazelcastInstance();IExecutorService service  = instance.getExecutorService(SERVICE_NAME);service.execute(new SpunMaster());service.execute(new SpunSlave());try {Thread.sleep(10000);} catch(InterruptedException ie) {System.out.println("Hey we got out sooner than I expected");} finally {instance.shutdown();System.exit(0);}}public static class SpunMaster implements Serializable, Runnable, HazelcastInstanceAware {private transient HazelcastInstance instance;private long counter = 0;@Overridepublic void run() {ILock lock = instance.getLock(LOCK_NAME);ICountDownLatch latch = instance.getCountDownLatch(LATCH_NAME);IList list = instance.getList(LIST_NAME);lock.lock();            try {latch.trySetCount(10);populate(list, latch);} finally {System.out.println("Master exiting stage left");lock.unlock();}}@Overridepublic void setHazelcastInstance(HazelcastInstance hazelcastInstance) {instance = hazelcastInstance;}private void populate(IList list, ICountDownLatch latch) {System.out.println("Populating list");long currentCounter = counter;for(; counter < currentCounter + 10; counter++) {list.add(counter);latch.countDown();}}}public static class SpunSlave implements Serializable, Runnable, HazelcastInstanceAware {private transient HazelcastInstance instance;@Overridepublic void run() {ILock lock = instance.getLock(LOCK_NAME);ICountDownLatch latch = instance.getCountDownLatch(LATCH_NAME);IList list = instance.getList(LIST_NAME);lock.lock();            try {if(latch.await(2, TimeUnit.SECONDS)) {while(!list.isEmpty()){System.out.println("value is " + list.get(0));list.remove(0);}}} catch(InterruptedException ie) {System.out.println("We had an interrupt");} finally {System.out.println("Slave exiting stage right");lock.unlock();}}@Overridepublic void setHazelcastInstance(HazelcastInstance hazelcastInstance) {instance = hazelcastInstance;}}}

等量线

组态

这是ISemaphore配置:

<?xml version="1.0" encoding="UTF-8"?>
<hazelcast
xsi:schemaLocation ="http://www.hazelcast.com/schema/config
http://www.hazelcast.com/schema/config/hazelcast-config-3.0.xsd "
xmlns ="http://www.hazelcast.com/schema/config "
xmlns:xsi ="http://www.w3.org/2001/XMLSchema-instance"><network><join><multicast enabled="true"/></join></network><semaphore name="to reduce access"><initial-permits>3</initial-permits></semaphore>
</hazelcast>

范例程式码

package hazelcastprimitives.isemaphore;import com.hazelcast.core.Hazelcast;
import com.hazelcast.core.HazelcastInstance;
import com.hazelcast.core.HazelcastInstanceAware;
import com.hazelcast.core.IExecutorService;
import com.hazelcast.core.ISemaphore;
import com.hazelcast.core.IdGenerator;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;/**** @author Daryl*/
public class ISemaphoreExample {static final String SEMAPHORE_NAME = "to reduce access";static final String GENERATOR_NAME = "to use";/*** @param args the command line arguments*/public static void main(String[] args) {HazelcastInstance instance = Hazelcast.newHazelcastInstance();IExecutorService service = instance.getExecutorService("service");List<Future> futures = new ArrayList(10);try {for(int i = 0; i < 10; i++) {futures.add(service.submit(new GeneratorUser(i)));}// so I wait til the last man.  No this may not be scalable.for(Future future: futures) {future.get();}} catch(InterruptedException ie){System.out.printf("Got interrupted.");} catch(ExecutionException ee) {System.out.printf("Cannot execute on Future. reason: %s\n", ee.toString());} finally {service.shutdown();instance.shutdown();}}static class GeneratorUser implements Callable, Serializable, HazelcastInstanceAware {private transient HazelcastInstance instance;private final int number;public GeneratorUser(int number) {this.number = number;}@Overridepublic Long call() {ISemaphore semaphore = instance.getSemaphore(SEMAPHORE_NAME);IdGenerator gen = instance.getIdGenerator(GENERATOR_NAME);long lastId = -1;try {semaphore.acquire();try {for(int i = 0; i < 10; i++){lastId = gen.newId();System.out.printf("current value of generator on %d is %d\n", number, lastId);Thread.sleep(1000);}} catch(InterruptedException ie) {System.out.printf("User %d was Interrupted\n", number);} finally {semaphore.release();}} catch(InterruptedException ie) {System.out.printf("User %d Got interrupted\n", number);}System.out.printf("User %d is leaving\n", number);return lastId;}@Overridepublic void setHazelcastInstance(HazelcastInstance hazelcastInstance) {instance = hazelcastInstance;}}}

结论

在这篇文章中讨论了Hazelcast的原语。 大多数(如果不是全部)都围绕线程协调展开。 分享了原始和个人经历的解释。 在示例中,显示了不同类型的协调。 可以通过以下版本的http://darylmathisonblog.googlecode.com/svn/trunk/HazelcastPrimitives下载示例。

参考文献

  • 《榛树之书》:可在www.hazelcast.com上找到
  • Hazelcast文档:在Hazelcast下载发现在发现www.hazelcast.org

翻译自: https://www.javacodegeeks.com/2014/10/beginners-guide-to-hazelcast-part-3.html

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/362320.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

Windows与Linux下进程间通信技术比较

一般我们写的程序都是以单个进程的方式来运行的&#xff0c;比较少涉及到多进程。特别是在windows下&#xff0c;因为Windows是按照线程来分配CPU时间片的&#xff0c;线程是最小的调度单位&#xff0c;所以在Windows下更多的用到多线程&#xff0c;在同一个进程里创建多个线程…

JSONP 原理

HTML 中 script 标签可以加载其他域下的js&#xff0c;比如我们经常引入一个其他域下线上cdn的jQuery。那如何利用这个特性实现从其他域下获取数据呢&#xff1f; 可以先这样试试&#xff1a; <script src"http://api.jirengu.com/weather.php"></script&g…

最长公共前缀(lca+trie树)

问题描述 给出一些串&#xff0c;多组询问求两个串的最长公共前缀。字符串总长 < 10^6。 输入格式 第一行一个整数n&#xff0c;表示字符串的个数。 接下来n行&#xff0c;每行一个字符串&#xff08;字符串不含空格&#xff09;。 第n2行一个整数m&#xff0c;表示询问总数…

vue笔记(三)生命周期、组件(嵌套)、数据传递

生命周期文档 一、生命周期 1、参考一 2、参考二 二、自定义组件 1. 使用&#xff1a;<组件名></组件名> 2. 定义组件&#xff1a; &#xff08;1&#xff09;方法一&#xff1a;官网 let 组件变量名 Vue.extend({template:<div class"header"&…

实用程序类的OOP替代

实用程序类&#xff08;也称为帮助程序类&#xff09;是仅具有静态方法且不封装任何状态的“结构”。 StringUtils &#xff0c; IOUtils &#xff0c; FileUtils从Apache的共享 ; Guava的 Iterables和Iterators以及JDK7的Files是实用程序类的完美示例。 这种设计思想在Java世…

神州泰岳2050万元收买并增资奇点国际

网易科技讯 3月7日消息&#xff0c;神州泰岳来日诰日颁布发表关照公告&#xff0c;将经由股权让渡体例共付出1450万元股权让渡款获得奇点国际100%股权&#xff0c;同时神州泰岳与邵起明分别出资600万元、200万元对奇点国际举行增资。本次增资后&#xff0c;奇点国际注册资金增进…

Vue 状态管理 Vuex

1、概述 Vuex作为插件&#xff0c;管理和维护整个项目的组件状态。 2、安装vuex cnpm i --save vuex 3、vuex使用 github地址&#xff1a;https://github.com/MengFangui/Vuex new Vue({el: #app,router: router,//使用vuexstore: store,render: h > {return h(App)}}); …

拯救你丢失的精度——BigInteger和BigDecimal类(入门)

第三阶段 JAVA常见对象的学习 BigInteger和BigDecimal类 BigInteger类 (一) 构造方法&#xff1a; //针对超过整数范围的运算(整数最大值&#xff1a;2147483647) BigInteger(String val) (二) 常用方法&#xff1a; //加 public BigInteger add(BigInteger val) //减 public…

vue笔记(四)注册组件,路由,vuex

官网 一、项目中的组件注册 二、路由 三、vuex 一、项目中的组件注册 1. 全局 import Loading from /components/loading;//封装的loading组件 Vue.component(Loading,Loading);2. 局部 <loading/>important loading from ./components/loadingcomponents:{loading}二…

#102030:在30天内运行20 10K,庆祝Java 20年

1995年5月23日是技术史上的重要时刻。 业界似乎并没有意识到当天发布的语言会在未来几年内完全改变技术的格局。 Java将在今年的同一天庆祝20岁生日。 Java 20年&#xff0c;哇&#xff01; 回顾20年前的存储器时代&#xff0c;思考一下Java的发明时间/方式。 万维网专用于精…

Java第二次实训

/*3、按要求编写一个Java应用程序&#xff1a; &#xff08;1&#xff09;定义一个类&#xff0c;描述一个矩形&#xff0c;包含有长、宽两种属性&#xff0c;和计算面积方法。 &#xff08;2&#xff09;编写一个类&#xff0c;继承自矩形类&#xff0c;同时该类描述长方体&am…

vue笔记(一)基本使用、数据检测

vue 官网 Vue (读音 /vjuː/&#xff0c;类似于 view) 是一套用于构建用户界面的渐进式框架。与其它大型框架不同的是&#xff0c;Vue 被设计为可以自底向上逐层应用。 一、基本使用 二、数据检测 一、Vue的思想 MVC【参考 nd的博客园】&#xff1a; 名称描述M&#xff08;…

Hazelcast入门指南第2部分

本文是我开始以Hazelcast &#xff08;分布式内存数据库&#xff09;为特色的系列文章的继续。 如果尚未阅读第一篇文章&#xff0c;请单击此处 。 分布式馆藏 Hazelcast具有许多可用于存储数据的分布式集合。 以下是它们的列表&#xff1a; 清单 我设置 队列 清单 IList是…

防止DISCUZ根域名跳转到forum.php的方法

症状&#xff1a;输入http://www.sn03.com/跳转到www.cn03.com/forum.php&#xff0c;这样有两个不好&#xff0c;1、用户复制时不利于传播&#xff0c;2、两个页面内容的重复对搜索引擎排名不利&#xff0c;如何取消这个呢&#xff1f; 全局-域名设置-应用域名-默认&#xff1…

Hazelcast入门指南第1部分

介绍 我将在Hazelcast上做一个系列。 我从Twitter了解了该产品。 他们决定跟随我&#xff0c;经过对他们所做工作的研究后&#xff0c;我决定跟随他们。 我在推特上说&#xff0c;Hazelcast将是分布式密码破解者的重要Struts。 这引起了一些兴趣&#xff0c;我决定加入一个。 H…

Vue 组件与复用

&#xff08;1&#xff09;全局注册 <!DOCTYPE html><html lang"zh"><head><meta charset"UTF-8" /><title>Vue</title></head><body><div id"app"><my-component></my-compone…

js笔记(二)数组、对象、this

大标题小节一、数组1. 数组的创建、赋值、分类&#xff1b;2. 数组的简单操作&#xff08;根据索引增、查、改&#xff09;&#xff1b;3. 声明式和构造函数创建的数组的区别&#xff1b;4.数组的方法&#xff1a;push()、unshift()、splice()、pop()、shift()、slice()、sort(…

Oracle SYSAUX 表空间 说明

一. SYSAUX 说明 在Oracle 10g 版本中&#xff0c;引入了SYSTEM表空间的一个辅助表空间&#xff1a; SYSAUX表空间。 SYSAUX 表空间存放一些其他的metadata组件&#xff0c;如OEM,Streams 等会默认存放在SYSAUX表空间里。这样也能降低SYSTEM表空间的负载。 因此SYSAUX 表空间也…

JAXB –新手的观点,第2部分

在本系列的第1部分中&#xff0c;我讨论了使用JAXB和JPA将数据从XML文件加载到数据库中的基础知识。 &#xff08;如果需要使用JSON而不是XML&#xff0c;则相同的想法应转化为类似Jackson的工具。&#xff09;该方法是使用共享域对象-即&#xff0c;一组带有描述XML映射和关系…

[C++Primer] 第二章 变量和基本类型

第二章 变量和基本类型 引用 引用定义的时候必须初始化。引用初始化之后无法重新绑定到其它对象上。引用本身并不是对象&#xff0c;所以没有指向引用的引用&#xff08;不管如何多层引用&#xff0c;引用的还是源对象&#xff09;下面用一个简单的例子说明&#xff1a; int a1…