Java 8 AtomicReference - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 AtomicReference class.

This code example shows how to use the following methods: get
package org.infinispan.api.batch; 
 
import org.infinispan.Cache; 
import org.infinispan.test.AbstractInfinispanTest; 
 
import java.util.concurrent.atomic.AtomicReference;
 
public abstract class AbstractBatchTest extends AbstractInfinispanTest { 
   protected String getOnDifferentThread(final Cache<String, String> cache, final String key) throws InterruptedException {
      final AtomicReference<String> ref = new AtomicReference<String>();
      Thread t = new Thread() {
         public void run() { 
            cache.startBatch(); 
            ref.set(cache.get(key));
            cache.endBatch(true); 
         } 
      }; 
 
      t.start();
      t.join();

8
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:
    private final DiscoveryNode sourceNode;
    private final String tempFilePrefix;
    private final Store store;
    private final RecoveryTarget.RecoveryListener listener;
 
    private AtomicReference<Thread> waitingRecoveryThread = new AtomicReference<>();
 
    private final AtomicBoolean finished = new AtomicBoolean();
 
    private final ConcurrentMap<String, IndexOutput> openIndexOutputs = ConcurrentCollections.newConcurrentMap();
    private final Store.LegacyChecksums legacyChecksums = new Store.LegacyChecksums();
 
    public RecoveryStatus(InternalIndexShard indexShard, DiscoveryNode sourceNode, RecoveryState state, RecoveryTarget.RecoveryListener listener) {
        super("recovery_status"); 
        this.recoveryId = idGenerator.incrementAndGet();
        this.listener = listener;
        this.logger = Loggers.getLogger(getClass(), indexShard.indexSettings(), indexShard.shardId());
        this.indexShard = indexShard;
        this.sourceNode = sourceNode;
        this.shardId = indexShard.shardId();
Full Snippet Info
8
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods: get
This code example shows how to use the following methods: compareAndSet, get
    } 
 
    @Override 
    public L getLocalContext() { 
        if (this.localContextFactory == null) return null;
        L localContext = this.localContext.get();
        if (localContext == null) {
            localContext = this.localContextFactory.createLocalContext();
            if (!this.localContext.compareAndSet(null, localContext)) {
                return this.localContext.get();
            } 
        } 
        return localContext;
    } 
} 
Full Snippet Info
8
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods: get
     * As a result we wait and add the Canvas prior to attempting to create the Player but  
     * only for MFPlayer. 
     */ 
    private Player createWindows7MFPlayer(File file, final Container parentComponent) throws IncompatibleSourceException {
         //DS failed.  Now we try MF. 
         final AtomicReference<Canvas> mfCanvas = new AtomicReference<Canvas>();  
         try { 
             //create new canvas and add to parentComponent so we can get an hwnd 
             SwingUtilities.invokeAndWait(new Runnable() { 
                 @Override 
                 public void run() { 
                     Canvas canvas = new Canvas(); 
                     parentComponent.add(canvas); 
                     //addNotify to make sure we have a working hwnd 
                     parentComponent.addNotify(); 
                     mfCanvas.set(canvas); 
                 } 
             }); 
         } catch (InterruptedException e) { 
             throw new IncompatibleSourceException(e.toString() + " \n" + ExceptionUtils.getStackTrace(e)); 

8
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:
    private final SessionAttributes attributes = mock(SessionAttributes.class); 
    private final SessionContext context = mock(SessionContext.class); 
    private final Mutator mutator = mock(Mutator.class); 
    private final Remover<String> remover = mock(Remover.class); 
    private final LocalContextFactory<Object> localContextFactory = mock(LocalContextFactory.class); 
    private final AtomicReference<Object> localContextRef = new AtomicReference<>(); 
 
    private final Session<Object> session = new InfinispanSession<>(this.id, this.metaData, this.attributes, this.localContextRef, this.localContextFactory, this.context, this.mutator, this.remover); 
     
    @Test 
    public void getId() { 
        assertSame(this.id, this.session.getId()); 
    } 
     
    @Test 
    public void getAttributes() { 
        assertSame(this.attributes, this.session.getAttributes()); 
         
        this.session.invalidate(); 
         
Full Snippet Info
8
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods: get
        public void onRequest(AtmosphereResource e) throws IOException {
        } 
 
        @Override 
        public void onStateChange(AtmosphereResourceEvent e) throws IOException {
            value.get().add(e.getResource());
        } 
 
        @Override 
        public void destroy() { 
        } 
    } 
} 
Full Snippet Info
8
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods: get
        sendAndRequest(""); 
    } 
 
    private void sendAndRequest(String inputMessage) throws Exception {
        CountDownLatch latch = new CountDownLatch(1);
        AtomicReference<String> message = new AtomicReference<String>();
 
        Object component = getComponent("testComponent"); 
        assertNotNull(component); 
        assertTrue("FunctionalTestComponent expected", component instanceof FunctionalTestComponent); 
        FunctionalTestComponent ftc = (FunctionalTestComponent) component;
        ftc.setEventCallback(new FunctionalEventCallback(latch, message));
 
        MuleClient client = muleContext.getClient();
        client.dispatch(getMuleFtpEndpoint(), inputMessage, null);
 
        // TODO DZ: need a reliable way to check the file once it's been written to 
        // the ftp server. Currently, once mule processes the ftp'd file, it 
        // auto-deletes it, so we can't check it 
        //assertTrue(getFtpClient().expectFileCount("/", 1, 10000)); 

8
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:
amazonEC2Client = EasyMock.createMock(AmazonEC2Client.class);
    runInstancesResult = EasyMock.createMock(RunInstancesResult.class);
    describeInstancesResult = EasyMock.createMock(DescribeInstancesResult.class);
    reservation = EasyMock.createMock(Reservation.class);
    workerSetupData = new AtomicReference<WorkerSetupData>(null);
 
    instance = new Instance()
        .withInstanceId(INSTANCE_ID)
        .withLaunchTime(new Date())
        .withImageId(AMI_ID)
        .withPrivateIpAddress(IP);
 
    strategy = new EC2AutoScalingStrategy(
        new DefaultObjectMapper(), 
        amazonEC2Client,
        new SimpleResourceManagementConfig().setWorkerPort(8080).setWorkerVersion(""), 
        DSuppliers.of(workerSetupData)
    ); 
  } 

7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:
   * @param ctx the {@link ChannelHandlerContext} for the attachment. 
   * @param attachment the attachment to set 
   */ 
  public void setAttachment(ChannelHandlerContext ctx, T attachment)
  { 
    AtomicReference<T> atomicRef = new AtomicReference<T>(attachment);
    ctx.setAttachment(atomicRef);
  } 
 
  /** 
   * Remove any attachment from the {@link ChannelHandlerContext}. It is safe to call this 
   * method in multiple threads since the actual attachment can be returned only once. 
   * 
   * @param ctx the {@link ChannelHandlerContext} for the attachment. 
   * @return the attachment which was removed, or null if no attachment exists. 
   */ 
  public T removeAttachment(ChannelHandlerContext ctx)
  { 
    @SuppressWarnings("unchecked") 
    AtomicReference<T> atomicRef = (AtomicReference<T>)ctx.getAttachment();
Full Snippet Info
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
See Code Examples for Java 8 AtomicReference Methods: