com.hazelcast.core.IAtomicLong Java Examples
The following examples show how to use
com.hazelcast.core.IAtomicLong.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AtomicExample.java From chuidiang-ejemplos with GNU Lesser General Public License v3.0 | 6 votes |
public static void main( String[] args ) throws FileNotFoundException, InterruptedException { Config config = new Config(); HazelcastInstance hazelcastInstance = Hazelcast.newHazelcastInstance(config); IAtomicLong atomicLong = hazelcastInstance.getAtomicLong("soy productor"); boolean cambiado = atomicLong.compareAndSet(0, 1); if (cambiado){ produce(hazelcastInstance); } else { consume(hazelcastInstance); } }
Example #2
Source File: AtomicLongTest.java From hazelcast-simulator with Apache License 2.0 | 5 votes |
@Setup public void setup() { counters = new IAtomicLong[countersLength]; for (int i = 0; i < countersLength; i++) { counters[i] = targetInstance.getAtomicLong("" + i); counters[i].get(); } }
Example #3
Source File: WebConfigurerTest.java From flair-engine with Apache License 2.0 | 4 votes |
@Override public IAtomicLong getAtomicLong(String s) { return null; }
Example #4
Source File: ServerApp.java From java-11-examples with Apache License 2.0 | 4 votes |
public void startServer() throws Exception { LOG.info("starting hazelcast ..."); executorService = Executors.newSingleThreadExecutor(); // Register serializers in hazelcast configuration SerializerConfig sc = new SerializerConfig() .setImplementation(new InstanceInfoSerializer()) .setTypeClass(InstanceInfo.class); Config config = new Config(); config.getSerializationConfig().addSerializerConfig(sc); // Create hazelcast instance hazelcastInstance = Hazelcast.newHazelcastInstance(config); MembershipListenerImpl membershipListener = new MembershipListenerImpl(expectedClusterSize); // listen on cluster events Cluster cluster = hazelcastInstance.getCluster(); cluster.addMembershipListener(membershipListener); LOG.info("Waiting for expected cluster members to join ..."); membershipListener.awaitClusterFormation(20, TimeUnit.SECONDS); // populate clusterInfo map IAtomicLong webPortCounter = hazelcastInstance.getAtomicLong("webPortCounter"); Map<String, InstanceInfo> clusterInfo = hazelcastInstance.getMap( "clusterInfo" ); InstanceInfo instanceInfo = createInstanceInfo(cluster.getLocalMember(), clusterInfo, (int)webPortCounter.getAndAdd(1)); clusterInfo.put(instanceInfo.getId(), instanceInfo); // register leadership listener GateKeepingListener gateKeepingListener = new GateKeepingListenerImpl(); GateKeeperRunnable gateKeeperRunnable = new GateKeeperRunnable(executorService, hazelcastInstance, gateKeepingListener); executorService.submit(gateKeeperRunnable); LOG.info("initializing service layer ..."); MessageService messageService = new MessageServiceImpl(hazelcastInstance); RequestRouter requestRouter = new RequestRouter(messageService); LOG.info("starting web layer ..."); server = new Server(); ServletContextHandler context = new ServletContextHandler(server, "/data", ServletContextHandler.SESSIONS); // Register websocket handlers ServletHolder webSocketHolder = new ServletHolder(new WsServlet(requestRouter)); context.addServlet(webSocketHolder, "/websocket"); // Setup http connectors HttpConfiguration httpConfig = new HttpConfiguration(); HttpConnectionFactory httpConnectionFactory = new HttpConnectionFactory(httpConfig); ServerConnector http = new ServerConnector(server, httpConnectionFactory); http.setPort(instanceInfo.getWebServerPort()); server.addConnector(http); server.start(); LOG.info("init sequence done."); }
Example #5
Source File: HazelcastAtomicLong.java From hazelcast-locks with Apache License 2.0 | 4 votes |
public HazelcastAtomicLong(IAtomicLong delegate) { this.delegate = delegate; }
Example #6
Source File: AtomicLongTest.java From hazelcast-simulator with Apache License 2.0 | 4 votes |
private IAtomicLong randomCounter() { int index = randomInt(counters.length); return counters[index]; }
Example #7
Source File: AtomicLongTest.java From hazelcast-simulator with Apache License 2.0 | 4 votes |
@Teardown public void teardown() { for (IAtomicLong counter : counters) { counter.destroy(); } }
Example #8
Source File: HazelcastTest.java From hazelcast-simulator with Apache License 2.0 | 4 votes |
public IAtomicLong getAtomicLong(String name) { return targetInstance.getDistributedObject("hz:impl:atomicLongService", name); }