List of usage examples for java.lang Boolean getBoolean
public static boolean getBoolean(String name)
From source file:com.diversityarrays.kdxplore.curate.TrialDataEditor.java
private void loadVisualisationTools() { List<VisualisationTool> list = new ArrayList<>(); VisToolParams params = new VisToolParams(selectedValueStore, curationData, colorProviderFactory, suppressionHandler);/*from w w w . j a v a2 s .c o m*/ Shared.Log.d(TAG, "Visualisation Plugins: "); //$NON-NLS-1$ boolean useHardcoded = Boolean.getBoolean("USE_HARDCODED_VISTOOLS"); //$NON-NLS-1$ if (useHardcoded) { // TODO remove hard coded VisualisationTool generation once dynamic // loading works String[] vtoolClassNames = { "com.diversityarrays.kdxplore.heatmap.HeatMapVisualisationTool", //$NON-NLS-1$ "com.diversityarrays.kdxplore.boxplot.BoxPlotVisualisationTool", //$NON-NLS-1$ "com.diversityarrays.kdxplore.scatterplot.ScatterPlotVisualisationTool" //$NON-NLS-1$ }; for (String className : vtoolClassNames) { try { Class<?> clazz = Class.forName(className); if (VisualisationTool.class.isAssignableFrom(clazz)) { @SuppressWarnings("unchecked") Class<VisualisationTool> vtoolClass = (Class<VisualisationTool>) clazz; Constructor<VisualisationTool> ctor = vtoolClass.getConstructor(VisToolParams.class); VisualisationTool vtool = ctor.newInstance(params); list.add(vtool); Shared.Log.i(TAG, vtool.toString()); } else { Shared.Log.e(TAG, "VisualisationTool.class not assignable for instance of " + className); } } catch (ClassNotFoundException | NoSuchMethodException | InstantiationException | IllegalAccessException | InvocationTargetException e) { Shared.Log.e(TAG, "Unable to get VisualisationTool for " + className, e); } } } else { Iterator<VisualisationToolService> it = ServiceRegistry.lookupProviders(VisualisationToolService.class); while (it.hasNext()) { try { VisualisationToolService vtoolService = it.next(); VisualisationTool vtool = vtoolService.createVisualisationTool(params); list.add(vtool); System.out.println(vtool.toString()); } catch (java.util.ServiceConfigurationError error) { Shared.Log.e(TAG, "VisualisationToolService error", error); messages.printErrorLn("VisualisationToolService error: ", error); } } } visualisationTools = list.toArray(new VisualisationTool[list.size()]); toolController = new VisualisationToolController(selectedValueStore, visualisationTools); toolController.addSelectionChangeListener(visToolSelectionChangeListener); for (VisualisationTool tool : visualisationTools) { visualisationToolById.put(tool.getVisualisationToolId(), tool); } }
From source file:org.apache.oodt.cas.filemgr.system.XmlRpcFileManagerClient.java
public String ingestProduct(Product product, Metadata metadata, boolean clientTransfer) throws VersioningException, XmlRpcException, FileManagerException { try {/*from ww w .ja v a 2 s .c o m*/ // ingest product Vector<Object> argList = new Vector<Object>(); Map<String, Object> productHash = XmlRpcStructFactory.getXmlRpcProduct(product); argList.add(productHash); argList.add(metadata.getHashTable()); argList.add(clientTransfer); String productId = (String) client.execute("filemgr.ingestProduct", argList); if (clientTransfer) { LOG.log(Level.FINEST, "File Manager Client: clientTransfer enabled: " + "transfering product [" + product.getProductName() + "]"); // we need to transfer the product ourselves // make sure we have the product ID if (productId == null) { throw new Exception("Request to ingest product: " + product.getProductName() + " but no product ID returned from File " + "Manager ingest"); } if (dataTransfer == null) { throw new Exception("Request to ingest product: [" + product.getProductName() + "] using client transfer, but no " + "dataTransferer specified!"); } product.setProductId(productId); if (!Boolean.getBoolean("org.apache.oodt.cas.filemgr.serverside.versioning")) { // version the product Versioner versioner = GenericFileManagerObjectFactory .getVersionerFromClassName(product.getProductType().getVersioner()); if (versioner != null) { versioner.createDataStoreReferences(product, metadata); } // add the newly versioned references to the data store try { addProductReferences(product); } catch (CatalogException e) { LOG.log(Level.SEVERE, "ingestProduct: RepositoryManagerException " + "when adding Product References for Product : " + product.getProductName() + " to RepositoryManager: Message: " + e); throw e; } } else { product.setProductReferences(getProductReferences(product)); } // now transfer the product try { dataTransfer.transferProduct(product); // now update the product's transfer status in the data // store product.setTransferStatus(Product.STATUS_RECEIVED); try { setProductTransferStatus(product); } catch (CatalogException e) { LOG.log(Level.SEVERE, "ingestProduct: RepositoryManagerException " + "when updating product transfer status for Product: " + product.getProductName() + " Message: " + e); throw e; } } catch (Exception e) { LOG.log(Level.SEVERE, "ingestProduct: DataTransferException when transfering Product: " + product.getProductName() + ": Message: " + e); throw new DataTransferException(e); } } return productId; // error versioning file } catch (VersioningException e) { LOG.log(Level.SEVERE, e.getMessage()); LOG.log(Level.SEVERE, "ingestProduct: VersioningException when versioning Product: " + product.getProductName() + " with Versioner " + product.getProductType().getVersioner() + ": Message: " + e); throw new VersioningException(e); } catch (XmlRpcException e2) { LOG.log(Level.SEVERE, "Failed to ingest product [ name:" + product.getProductName() + "] :" + e2.getMessage() + " -- rolling back ingest"); try { Vector<Object> argList = new Vector<Object>(); Map<String, Object> productHash = XmlRpcStructFactory.getXmlRpcProduct(product); argList.add(productHash); client.execute("filemgr.removeProduct", argList); } catch (Exception e1) { LOG.log(Level.SEVERE, "Failed to rollback ingest of product [" + product + "] : " + e2.getMessage()); } throw e2; } catch (Exception e) { LOG.log(Level.SEVERE, "Failed to ingest product [ id: " + product.getProductId() + "/ name:" + product.getProductName() + "] :" + e + " -- rolling back ingest"); try { Vector<Object> argList = new Vector<Object>(); Map<String, Object> productHash = XmlRpcStructFactory.getXmlRpcProduct(product); argList.add(productHash); client.execute("filemgr.removeProduct", argList); } catch (Exception e1) { LOG.log(Level.SEVERE, "Failed to rollback ingest of product [" + product + "] : " + e); } throw new FileManagerException("Failed to ingest product [" + product + "] : " + e); } }
From source file:org.rhq.enterprise.installer.ServerInformation.java
public boolean isUnsupportedJonFeaturesEnabled() { return Boolean.getBoolean(JON_UNSUPPORTED_FEATURES_ENABLED_SYSPROP); }
From source file:org.ejbca.core.protocol.ws.EjbcaWSTest.java
@Test public void test70CreateSoftCryptoToken() throws Exception { log.trace(">test70CreateSoftCryptoToken()"); // If this is community edition, then this method is not supported and the test is skipped boolean methodSupported = true; try {//from w w w . j a v a2s . c o m ejbcaraws.createCryptoToken(null, null, null, false, null); } catch (EjbcaException_Exception e) { if (e.getFaultInfo().getErrorCode().getInternalErrorCode() .equals(ErrorCode.UNSUPPORTED_METHOD.getInternalErrorCode())) { methodSupported = false; } } assumeTrue(methodSupported); String ctname = "NewTestCryptoTokenThroughWS"; // Remove any residues from earlier test runs Integer ctid = cryptoTokenManagementSession.getIdFromName(ctname); if (ctid != null) { cryptoTokenManagementSession.deleteCryptoToken(intAdmin, ctid.intValue()); } try { ArrayList<KeyValuePair> cryptotokenProperties = new ArrayList<KeyValuePair>(); cryptotokenProperties .add(new KeyValuePair(CryptoToken.ALLOW_EXTRACTABLE_PRIVATE_KEY, Boolean.toString(false))); cryptotokenProperties.add(new KeyValuePair(SoftCryptoToken.NODEFAULTPWD, Boolean.TRUE.toString())); ejbcaraws.createCryptoToken(ctname, "SoftCryptoToken", "1234", false, cryptotokenProperties); ctid = cryptoTokenManagementSession.getIdFromName(ctname); assertNotNull("Creating a new SoftCryptoToken failed", ctid); CryptoTokenInfo token = cryptoTokenManagementSession.getCryptoTokenInfo(intAdmin, ctid.intValue()); Properties ctproperties = token.getCryptoTokenProperties(); assertEquals(3, ctproperties.keySet().size()); assertTrue(ctproperties.containsKey(SoftCryptoToken.NODEFAULTPWD)); assertEquals(ctproperties.getProperty(SoftCryptoToken.NODEFAULTPWD), Boolean.TRUE.toString()); assertEquals("SoftCryptoToken", token.getType()); assertFalse(Boolean.getBoolean( (String) token.getCryptoTokenProperties().get(CryptoToken.ALLOW_EXTRACTABLE_PRIVATE_KEY))); assertTrue(token.isActive()); cryptoTokenManagementSession.deactivate(intAdmin, ctid.intValue()); assertFalse(cryptoTokenManagementSession.isCryptoTokenStatusActive(intAdmin, ctid.intValue())); cryptoTokenManagementSession.activate(intAdmin, ctid.intValue(), "1234".toCharArray()); assertTrue(cryptoTokenManagementSession.isCryptoTokenStatusActive(intAdmin, ctid.intValue())); } finally { ctid = cryptoTokenManagementSession.getIdFromName(ctname); if (ctid != null) { cryptoTokenManagementSession.deleteCryptoToken(intAdmin, ctid.intValue()); } } log.trace("<test70CreateSoftCryptoToken()"); }
From source file:org.apache.zookeeper.server.quorum.QuorumPeerMainTest.java
/** * Currently, in SNAP sync, the leader will start queuing the * proposal/commits and the NEWLEADER packet before sending * over the snapshot over wire. So it's possible that the zxid * associated with the snapshot might be higher than all the * packets queued before NEWLEADER.//from w ww . ja v a 2 s . co m * * When the follower received the snapshot, it will apply all * the txns queued before NEWLEADER, which may not cover all * the txns up to the zxid in the snapshot. After that, it * will write the snapshot out to disk with the zxid associated * with the snapshot. In case the server crashed after writing * this out, when loading the data from disk, it will use zxid * of the snapshot file to sync with leader, and it could cause * data inconsistent, because we only replayed partial of the * historical data during previous syncing. * * This test case is going to cover and simulate this scenario * and make sure there is no data inconsistency issue after fix. */ @Test public void testInconsistentDueToNewLeaderOrder() throws Exception { // 1. set up an ensemble with 3 servers final int ENSEMBLE_SERVERS = 3; final int clientPorts[] = new int[ENSEMBLE_SERVERS]; StringBuilder sb = new StringBuilder(); String server; for (int i = 0; i < ENSEMBLE_SERVERS; i++) { clientPorts[i] = PortAssignment.unique(); server = "server." + i + "=127.0.0.1:" + PortAssignment.unique() + ":" + PortAssignment.unique() + ":participant;127.0.0.1:" + clientPorts[i]; sb.append(server + "\n"); } String currentQuorumCfgSection = sb.toString(); // start servers MainThread[] mt = new MainThread[ENSEMBLE_SERVERS]; ZooKeeper zk[] = new ZooKeeper[ENSEMBLE_SERVERS]; Context contexts[] = new Context[ENSEMBLE_SERVERS]; for (int i = 0; i < ENSEMBLE_SERVERS; i++) { final Context context = new Context(); contexts[i] = context; mt[i] = new MainThread(i, clientPorts[i], currentQuorumCfgSection, false) { @Override public TestQPMain getTestQPMain() { return new CustomizedQPMain(context); } }; mt[i].start(); zk[i] = new ZooKeeper("127.0.0.1:" + clientPorts[i], ClientBase.CONNECTION_TIMEOUT, this); } waitForAll(zk, States.CONNECTED); LOG.info("all servers started"); String nodePath = "/testInconsistentDueToNewLeader"; int leaderId = -1; int followerA = -1; for (int i = 0; i < ENSEMBLE_SERVERS; i++) { if (mt[i].main.quorumPeer.leader != null) { leaderId = i; } else if (followerA == -1) { followerA = i; } } LOG.info("shutdown follower {}", followerA); mt[followerA].shutdown(); waitForOne(zk[followerA], States.CONNECTING); try { // 2. set force snapshot to be true LOG.info("force snapshot sync"); System.setProperty(LearnerHandler.FORCE_SNAP_SYNC, "true"); // 3. create a node String initialValue = "1"; final ZooKeeper leaderZk = zk[leaderId]; leaderZk.create(nodePath, initialValue.getBytes(), Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT); LOG.info("created node {} with value {}", nodePath, initialValue); CustomQuorumPeer leaderQuorumPeer = (CustomQuorumPeer) mt[leaderId].main.quorumPeer; // 4. on the customized leader catch the startForwarding call // (without synchronized), set the node to value v1, then // call the super.startForwarding to generate the ongoing // txn proposal and commit for v1 value update leaderQuorumPeer.setStartForwardingListener(new StartForwardingListener() { @Override public void start() { if (!Boolean.getBoolean(LearnerHandler.FORCE_SNAP_SYNC)) { return; } final String value = "2"; LOG.info("start forwarding, set {} to {}", nodePath, value); // use async, otherwise it will block the logLock in // ZKDatabase and the setData request will timeout try { leaderZk.setData(nodePath, value.getBytes(), -1, new AsyncCallback.StatCallback() { public void processResult(int rc, String path, Object ctx, Stat stat) { } }, null); // wait for the setData txn being populated Thread.sleep(1000); } catch (Exception e) { LOG.error("error when set {} to {}", nodePath, value, e); } } }); // 5. on the customized leader catch the beginSnapshot call in // LearnerSnapshotThrottler to set the node to value v2, // wait it hit data tree leaderQuorumPeer.setBeginSnapshotListener(new BeginSnapshotListener() { @Override public void start() { String value = "3"; LOG.info("before sending snapshot, set {} to {}", nodePath, value); try { leaderZk.setData(nodePath, value.getBytes(), -1); LOG.info("successfully set {} to {}", nodePath, value); } catch (Exception e) { LOG.error("error when set {} to {}, {}", nodePath, value, e); } } }); // 6. exit follower A after taking snapshot CustomQuorumPeer followerAQuorumPeer = ((CustomQuorumPeer) mt[followerA].main.quorumPeer); LOG.info("set exit when ack new leader packet on {}", followerA); contexts[followerA].exitWhenAckNewLeader = true; CountDownLatch latch = new CountDownLatch(1); final MainThread followerAMT = mt[followerA]; contexts[followerA].newLeaderAckCallback = new NewLeaderAckCallback() { @Override public void start() { try { latch.countDown(); followerAMT.shutdown(); } catch (Exception e) { } } }; // 7. start follower A to do snapshot sync LOG.info("starting follower {}", followerA); mt[followerA].start(); Assert.assertTrue(latch.await(30, TimeUnit.SECONDS)); // 8. now we have invalid data on disk, let's load it and verify LOG.info("disable exit when ack new leader packet on {}", followerA); System.setProperty(LearnerHandler.FORCE_SNAP_SYNC, "false"); contexts[followerA].exitWhenAckNewLeader = true; contexts[followerA].newLeaderAckCallback = null; LOG.info("restarting follower {}", followerA); mt[followerA].start(); zk[followerA].close(); zk[followerA] = new ZooKeeper("127.0.0.1:" + clientPorts[followerA], ClientBase.CONNECTION_TIMEOUT, this); // 9. start follower A, after it's in broadcast state, make sure // the node value is same as what we have on leader waitForOne(zk[followerA], States.CONNECTED); Assert.assertEquals(new String(zk[followerA].getData(nodePath, null, null)), new String(zk[leaderId].getData(nodePath, null, null))); } finally { System.clearProperty(LearnerHandler.FORCE_SNAP_SYNC); for (int i = 0; i < ENSEMBLE_SERVERS; i++) { mt[i].shutdown(); zk[i].close(); } } }
From source file:org.apache.cassandra.config.DatabaseDescriptor.java
public static boolean getDisableSTCSInL0() { return Boolean.getBoolean("cassandra.disable_stcs_in_l0"); }
From source file:org.lockss.config.ConfigManager.java
boolean isUnitTesting() { return Boolean.getBoolean("org.lockss.unitTesting"); }
From source file:org.lockss.test.LockssTestCase.java
/** * Close the socket after a timeout/*from w w w . j a va2 s . c om*/ * @param inMs interval to wait before interrupting * @param sock the Socket to close * @return a SockAbort */ public SockAbort abortIn(long inMs, Socket sock) { SockAbort sa = new SockAbort(inMs, sock); if (Boolean.getBoolean("org.lockss.test.threadDump")) { sa.setThreadDump(); } sa.start(); return sa; }
From source file:org.lockss.test.LockssTestCase.java
/** * Close the socket after a timeout/*from ww w.j a va 2 s. c o m*/ * @param inMs interval to wait before interrupting * @param sock the ServerSocket to close * @return a SockAbort */ public SockAbort abortIn(long inMs, ServerSocket sock) { SockAbort sa = new SockAbort(inMs, sock); if (Boolean.getBoolean("org.lockss.test.threadDump")) { sa.setThreadDump(); } sa.start(); return sa; }