Code example for AtomicReference

0
  @Before 
  public void setUp() throws Exception 
  { 
    autoScalingStrategy = EasyMock.createMock(AutoScalingStrategy.class);
    workerSetupData = new AtomicReference<>(
        new WorkerSetupData( 
            "0", 0, 2, null, null, null 
        ) 
    ); 
 
    testTask = new TestMergeTask(
        "task1", 
        "dummyDs", 
        Lists.<DataSegment>newArrayList( 
            new DataSegment( 
                "dummyDs", 
                new Interval("2012-01-01/2012-01-02"), 
                new DateTime().toString(), 
                null, 
                null, 
                null, 
                null, 
                0, 
                0 
            ) 
        ), 
        Lists.<AggregatorFactory>newArrayList() 
    ); 
    simpleResourceManagementStrategy = new SimpleResourceManagementStrategy(
        autoScalingStrategy,
        new SimpleResourceManagementConfig() 
            .setWorkerIdleTimeout(new Period(0)) 
            .setMaxScalingDuration(new Period(1000)) 
            .setNumEventsToTrack(1) 
            .setPendingTaskTimeout(new Period(0)) 
            .setWorkerVersion(""), 
        DSuppliers.of(workerSetupData)
    ); 
  } 
 
  @Test 
  public void testSuccessfulProvision() throws Exception