Example usage for java.util.concurrent.atomic AtomicBoolean set

List of usage examples for java.util.concurrent.atomic AtomicBoolean set

Introduction

In this page you can find the example usage for java.util.concurrent.atomic AtomicBoolean set.

Prototype

public final void set(boolean newValue) 

Source Link

Document

Sets the value to newValue , with memory effects as specified by VarHandle#setVolatile .

Usage

From source file:org.apache.hadoop.hive.ql.TestTxnCommands2.java

private void testOrcPPD(boolean enablePPD) throws Exception {
    boolean originalPpd = hiveConf.getBoolVar(HiveConf.ConfVars.HIVEOPTINDEXFILTER);
    hiveConf.setBoolVar(HiveConf.ConfVars.HIVEOPTINDEXFILTER, enablePPD);//enables ORC PPD
    int[][] tableData = { { 1, 2 }, { 3, 4 } };
    runStatementOnDriver("insert into " + Table.ACIDTBL + "(a,b) " + makeValuesClause(tableData));
    runStatementOnDriver("alter table " + Table.ACIDTBL + " compact 'MAJOR'");
    Worker t = new Worker();
    t.setThreadId((int) t.getId());
    t.setHiveConf(hiveConf);//from  w w w.ja  v a  2 s. c o m
    AtomicBoolean stop = new AtomicBoolean();
    AtomicBoolean looped = new AtomicBoolean();
    stop.set(true);
    t.init(stop, looped);
    t.run();
    //now we have base_0001 file
    int[][] tableData2 = { { 1, 7 }, { 5, 6 }, { 7, 8 }, { 9, 10 } };
    runStatementOnDriver("insert into " + Table.ACIDTBL + "(a,b) " + makeValuesClause(tableData2));
    //now we have delta_0002_0002_0000 with inserts only (ok to push predicate)
    runStatementOnDriver("delete from " + Table.ACIDTBL + " where a=7 and b=8");
    //now we have delta_0003_0003_0000 with delete events (can't push predicate)
    runStatementOnDriver("update " + Table.ACIDTBL + " set b = 11 where a = 9");
    //and another delta with update op
    List<String> rs1 = runStatementOnDriver("select a,b from " + Table.ACIDTBL + " where a > 1 order by a,b");
    int[][] resultData = { { 3, 4 }, { 5, 6 }, { 9, 11 } };
    Assert.assertEquals("Update failed", stringifyValues(resultData), rs1);
    hiveConf.setBoolVar(HiveConf.ConfVars.HIVEOPTINDEXFILTER, originalPpd);
}

From source file:com.example.app.ui.DemoUserProfileEditor.java

@Override
public boolean validateUIValue(final Notifiable notifiable) {
    final AtomicBoolean valid = new AtomicBoolean(true);
    _forEach(value -> valid.set(value.validateUIValue(notifiable) && valid.get()));
    return valid.get();
}

From source file:com.jayway.restassured.path.json.JsonPathObjectDeserializationTest.java

@Test
public void json_path_supports_custom_deserializer() {
    // Given/*from w  w  w  .  ja v  a 2  s .c  o  m*/
    final AtomicBoolean customDeserializerUsed = new AtomicBoolean(false);

    final JsonPath jsonPath = new JsonPath(GREETING)
            .using(new JsonPathConfig().defaultObjectDeserializer(new JsonPathObjectDeserializer() {
                public <T> T deserialize(ObjectDeserializationContext ctx) {
                    customDeserializerUsed.set(true);
                    final String json = ctx.getDataToDeserialize().asString();
                    final Greeting greeting = new Greeting();
                    greeting.setFirstName(StringUtils.substringBetween(json, "\"firstName\":\"", "\""));
                    greeting.setLastName(StringUtils.substringBetween(json, "\"lastName\":\"", "\""));
                    return (T) greeting;
                }
            }));

    // When
    final Greeting greeting = jsonPath.getObject("", Greeting.class);

    // Then
    assertThat(greeting.getFirstName(), equalTo("John"));
    assertThat(greeting.getLastName(), equalTo("Doe"));
    assertThat(customDeserializerUsed.get(), is(true));
}

From source file:net.sourceforge.ganttproject.io.CsvImportTest.java

public void testSkipUntilFirstHeader() throws IOException {
    String notHeader = "FOO, BAR, A";
    String header = "A, B";
    String data = "a1, b1";
    final AtomicBoolean wasCalled = new AtomicBoolean(false);
    GanttCSVOpen.RecordGroup recordGroup = new GanttCSVOpen.RecordGroup("ABC",
            ImmutableSet.<String>of("A", "B")) {
        @Override//from w w w .  ja v  a  2  s  .c om
        protected boolean doProcess(CSVRecord record) {
            wasCalled.set(true);
            assertEquals("a1", record.get("A"));
            assertEquals("b1", record.get("B"));
            return true;
        }
    };
    GanttCSVOpen importer = new GanttCSVOpen(createSupplier(Joiner.on('\n').join(notHeader, header, data)),
            recordGroup);
    importer.load();
    assertTrue(wasCalled.get());
    assertEquals(1, importer.getSkippedLineCount());
}

From source file:de.speexx.jira.jan.command.issuequery.CsvCreator.java

public void printIssueData(final IssueData issueData, final List<FieldName> historyFieldNames,
        final List<FieldNamePath> currentFieldNames, final TemporalChangeOutput temporalOutput,
        final AtomicBoolean header) {
    checkParameter(issueData, historyFieldNames, currentFieldNames, temporalOutput, header);

    if (header.get()) {
        printHeader(currentFieldNames, historyFieldNames, temporalOutput);
        header.set(false);
    }//  w ww. j a va  2 s  .co  m

    printIssueData(issueData, currentFieldNames, historyFieldNames, temporalOutput);
}

From source file:net.sourceforge.ganttproject.io.CsvImportTest.java

public void testBasic() throws Exception {
    String header = "A, B";
    String data = "a1, b1";
    final AtomicBoolean wasCalled = new AtomicBoolean(false);
    GanttCSVOpen.RecordGroup recordGroup = new GanttCSVOpen.RecordGroup("AB",
            ImmutableSet.<String>of("A", "B")) {
        @Override//from   ww w.  ja  v a  2 s  .com
        protected boolean doProcess(CSVRecord record) {
            wasCalled.set(true);
            assertEquals("a1", record.get("A"));
            assertEquals("b1", record.get("B"));
            return true;
        }
    };
    GanttCSVOpen importer = new GanttCSVOpen(createSupplier(Joiner.on('\n').join(header, data)), recordGroup);
    importer.load();
    assertTrue(wasCalled.get());

    // Now test with one empty line between header and data
    wasCalled.set(false);
    importer = new GanttCSVOpen(createSupplier(Joiner.on('\n').join(header, "", data)), recordGroup);
    importer.load();
    assertTrue(wasCalled.get());
}

From source file:ch.cyberduck.core.local.FinderLocalTest.java

@Test
public void testReleaseSecurityScopeBookmarkInputStreamClose() throws Exception {
    final AtomicBoolean released = new AtomicBoolean(false);
    FinderLocal l = new FinderLocal(System.getProperty("java.io.tmpdir"), UUID.randomUUID().toString()) {
        @Override/*from   www  . ja va  2s  .com*/
        public void release(final Object lock) {
            released.set(true);
            super.release(lock);
        }
    };
    new DefaultLocalTouchFeature().touch(l);
    final InputStream in = l.getInputStream();
    in.close();
    assertTrue(released.get());
    l.delete();
}

From source file:de.acosix.alfresco.mtsupport.repo.auth.TenantRoutingAuthenticationComponentFacade.java

/**
 * {@inheritDoc}/*from   w  ww .jav  a 2s.  c o m*/
 */
@Override
public boolean isActive() {
    final AtomicBoolean isActive = new AtomicBoolean(false);

    LOGGER.trace("Checking isActive for enabled tenants (until first active tenant)");
    for (final String tenantDomain : this.enabledTenants) {
        if (!isActive.get()) {
            isActive.set(this.isActive(tenantDomain));
        }
    }
    LOGGER.trace("Component is active: {}", isActive.get());

    return isActive.get();
}

From source file:de.dal33t.powerfolder.test.transfer.BandwidthLimitText.java

public void testBandwidthStats() {
    BandwidthLimiter bl = BandwidthLimiter.LAN_INPUT_BANDWIDTH_LIMITER;
    bl.setAvailable(0);/*from w  w w  .  ja v a  2s . c o  m*/
    provider.start();
    provider.setLimitBPS(bl, 1000);
    final AtomicBoolean gotStat = new AtomicBoolean();
    BandwidthStatsListener listener = new BandwidthStatsListener() {
        public void handleBandwidthStat(BandwidthStat stat) {
            System.out.println("Got a stat...");
            gotStat.set(true);
        }

        public boolean fireInEventDispatchThread() {
            return false;
        }
    };
    provider.addBandwidthStatListener(listener);
    try {
        Thread.sleep(2000);
    } catch (InterruptedException e) {
        fail(e.toString());
    }
    provider.removeLimiter(bl);
    provider.shutdown();
    assertTrue("Failed to get any stats?", gotStat.get());
}

From source file:com.spectralogic.ds3client.helpers.FileObjectGetter_Test.java

@Test
public void testThatFileReportsAsRegularOnWindows() throws IOException, InterruptedException {
    Assume.assumeTrue(Platform.isWindows());

    final String tempPathPrefix = null;
    final Path tempDirectory = Files.createTempDirectory(Paths.get("."), tempPathPrefix);

    final String A_FILE_NAME = "aFile.txt";

    final AtomicBoolean caughtException = new AtomicBoolean(false);

    try {//w w w .  j  a  v a  2  s . co  m
        Files.createFile(Paths.get(tempDirectory.toString(), A_FILE_NAME));
        new FileObjectGetter(tempDirectory).buildChannel(A_FILE_NAME);
    } catch (final UnrecoverableIOException e) {
        assertTrue(e.getMessage().contains(A_FILE_NAME));
        caughtException.set(true);
    } finally {
        FileUtils.deleteDirectory(tempDirectory.toFile());
    }

    assertFalse(caughtException.get());
}