private boolean verifyStringPropSet(String... keys) { for (String key : keys) { if (containsKey(key) && !getString(key).isEmpty()) { return true; } } log.info(keys[0] + " is not set"); return false; }
private boolean verifyStringPropNotSet(String... keys) { for (String key : keys) { if (containsKey(key) && !getString(key).isEmpty()) { log.info(key + " should not be set"); return false; } } return true; }
private boolean verifyStringPropNotSet(String... keys) { for (String key : keys) { if (containsKey(key) && !getString(key).isEmpty()) { log.info(key + " should not be set"); return false; } } return true; }
private String getDepNonEmptyString(String property, String depProperty) { if (containsKey(property)) { return getNonEmptyString(property); } else if (containsKey(depProperty)) { return getNonEmptyString(depProperty); } else { throw new NoSuchElementException(property + " is not set!"); } }
private String getDepNonEmptyString(String property, String depProperty) { if (containsKey(property)) { return getNonEmptyString(property); } else if (containsKey(depProperty)) { return getNonEmptyString(depProperty); } else { throw new NoSuchElementException(property + " is not set!"); } }
private boolean verifyStringPropSet(String... keys) { for (String key : keys) { if (containsKey(key) && !getString(key).isEmpty()) { return true; } } log.info(keys[0] + " is not set"); return false; }
/** * Gets the Apache Accumulo password property value {@value #ACCUMULO_PASSWORD_PROP} * * @throws NoSuchElementException if {@value #ACCUMULO_PASSWORD_PROP} is not set */ public String getAccumuloPassword() { if (containsKey(ACCUMULO_PASSWORD_PROP)) { return verifyNotNull(ACCUMULO_PASSWORD_PROP, getString(ACCUMULO_PASSWORD_PROP)); } else if (containsKey(CLIENT_ACCUMULO_PASSWORD_PROP)) { return verifyNotNull(CLIENT_ACCUMULO_PASSWORD_PROP, getString(CLIENT_ACCUMULO_PASSWORD_PROP)); } throw new NoSuchElementException(ACCUMULO_PASSWORD_PROP + " is not set!"); }
/** * Gets the Apache Accumulo password property value {@value #ACCUMULO_PASSWORD_PROP} * * @throws NoSuchElementException if {@value #ACCUMULO_PASSWORD_PROP} is not set */ public String getAccumuloPassword() { if (containsKey(ACCUMULO_PASSWORD_PROP)) { return verifyNotNull(ACCUMULO_PASSWORD_PROP, getString(ACCUMULO_PASSWORD_PROP)); } else if (containsKey(CLIENT_ACCUMULO_PASSWORD_PROP)) { return verifyNotNull(CLIENT_ACCUMULO_PASSWORD_PROP, getString(CLIENT_ACCUMULO_PASSWORD_PROP)); } throw new NoSuchElementException(ACCUMULO_PASSWORD_PROP + " is not set!"); }
/** * Returns the application name after verification to avoid characters Zookeeper does not like in * nodes and Hadoop does not like in HDFS paths. * <p> * Gets the value of the property {@value #CONNECTION_APPLICATION_NAME_PROP} if set * * @return The application name * @throws NoSuchElementException if the property has not been set */ public String getApplicationName() { String applicationName; if (containsKey(CONNECTION_APPLICATION_NAME_PROP)) { applicationName = getString(CONNECTION_APPLICATION_NAME_PROP); } else if (containsKey(CLIENT_APPLICATION_NAME_PROP)) { applicationName = getString(CLIENT_APPLICATION_NAME_PROP); } else { throw new NoSuchElementException(CONNECTION_APPLICATION_NAME_PROP + " was not set"); } verifyApplicationName(applicationName); return applicationName; }
private int getDepPositiveInt(String property, String depProperty, int defaultValue) { if (containsKey(property)) { return getInt(property, defaultValue); } else { return getInt(depProperty, defaultValue); } }
private String getDepNonEmptyString(String property, String depProperty, String defaultValue) { return containsKey(property) ? getNonEmptyString(property, defaultValue) : getNonEmptyString(depProperty, defaultValue); }
private int getDepPositiveInt(String property, String depProperty, int defaultValue) { if (containsKey(property)) { return getInt(property, defaultValue); } else { return getInt(depProperty, defaultValue); } }
/** * Returns the value of the property {@value #CONNECTION_RETRY_TIMEOUT_MS_PROP} if it is set, else * the default value of {@value #CONNECTION_RETRY_TIMEOUT_MS_DEFAULT}. The integer returned * represents milliseconds and is always positive. * * @since 1.2.0 */ public int getConnectionRetryTimeout() { int retval; if (containsKey(CONNECTION_RETRY_TIMEOUT_MS_PROP)) { retval = getInt(CONNECTION_RETRY_TIMEOUT_MS_PROP, CONNECTION_RETRY_TIMEOUT_MS_DEFAULT); } else { retval = getInt(CLIENT_RETRY_TIMEOUT_MS_PROP, CONNECTION_RETRY_TIMEOUT_MS_DEFAULT); } Preconditions.checkArgument(retval >= -1, CONNECTION_RETRY_TIMEOUT_MS_PROP + " must be >= -1"); return retval; }
/** * Returns the value of the property {@value #CONNECTION_RETRY_TIMEOUT_MS_PROP} if it is set, else * the default value of {@value #CONNECTION_RETRY_TIMEOUT_MS_DEFAULT}. The integer returned * represents milliseconds and is always positive. * * @since 1.2.0 */ public int getConnectionRetryTimeout() { int retval; if (containsKey(CONNECTION_RETRY_TIMEOUT_MS_PROP)) { retval = getInt(CONNECTION_RETRY_TIMEOUT_MS_PROP, CONNECTION_RETRY_TIMEOUT_MS_DEFAULT); } else { retval = getInt(CLIENT_RETRY_TIMEOUT_MS_PROP, CONNECTION_RETRY_TIMEOUT_MS_DEFAULT); } Preconditions.checkArgument(retval >= -1, CONNECTION_RETRY_TIMEOUT_MS_PROP + " must be >= -1"); return retval; }
/** * Returns the application name after verification to avoid characters Zookeeper does not like in * nodes and Hadoop does not like in HDFS paths. * <p> * Gets the value of the property {@value #CONNECTION_APPLICATION_NAME_PROP} if set * * @return The application name * @throws NoSuchElementException if the property has not been set */ public String getApplicationName() { String applicationName; if (containsKey(CONNECTION_APPLICATION_NAME_PROP)) { applicationName = getString(CONNECTION_APPLICATION_NAME_PROP); } else if (containsKey(CLIENT_APPLICATION_NAME_PROP)) { applicationName = getString(CLIENT_APPLICATION_NAME_PROP); } else { throw new NoSuchElementException(CONNECTION_APPLICATION_NAME_PROP + " was not set"); } verifyApplicationName(applicationName); return applicationName; }
private String getDepNonEmptyString(String property, String depProperty, String defaultValue) { return containsKey(property) ? getNonEmptyString(property, defaultValue) : getNonEmptyString(depProperty, defaultValue); }
private InetSocketAddress startServer() throws TTransportException { Preconditions.checkState( curatorFramework != null && curatorFramework.getState() == CuratorFrameworkState.STARTED); if (env.getConfiguration().containsKey(FluoConfigurationImpl.ORACLE_PORT_PROP)) { port = env.getConfiguration().getInt(FluoConfigurationImpl.ORACLE_PORT_PROP); Preconditions.checkArgument(port >= 1 && port <= 65535, FluoConfigurationImpl.ORACLE_PORT_PROP + " must be valid port (1-65535)"); } else { port = PortUtils.getRandomFreePort(); } InetSocketAddress addr = new InetSocketAddress(port); TNonblockingServerSocket socket = new TNonblockingServerSocket(addr); THsHaServer.Args serverArgs = new THsHaServer.Args(socket); TProcessor processor = new OracleService.Processor<OracleService.Iface>(this); serverArgs.processor(processor); serverArgs.maxReadBufferBytes = ORACLE_MAX_READ_BUFFER_BYTES; serverArgs.inputProtocolFactory(new TCompactProtocol.Factory()); serverArgs.outputProtocolFactory(new TCompactProtocol.Factory()); server = new THsHaServer(serverArgs); serverThread = new Thread(server::serve); serverThread.setDaemon(true); serverThread.start(); return addr; }
private InetSocketAddress startServer() throws TTransportException { if (env.getConfiguration().containsKey(FluoConfigurationImpl.ORACLE_PORT_PROP)) { port = env.getConfiguration().getInt(FluoConfigurationImpl.ORACLE_PORT_PROP); Preconditions.checkArgument(port >= 1 && port <= 65535, FluoConfigurationImpl.ORACLE_PORT_PROP + " must be valid port (1-65535)"); } else { port = PortUtils.getRandomFreePort(); } InetSocketAddress addr = new InetSocketAddress(port); TNonblockingServerSocket socket = new TNonblockingServerSocket(addr); THsHaServer.Args serverArgs = new THsHaServer.Args(socket); TProcessor processor = new OracleService.Processor<OracleService.Iface>(this); serverArgs.processor(processor); serverArgs.maxReadBufferBytes = ORACLE_MAX_READ_BUFFER_BYTES; serverArgs.inputProtocolFactory(new TCompactProtocol.Factory()); serverArgs.outputProtocolFactory(new TCompactProtocol.Factory()); server = new THsHaServer(serverArgs); Runnable st = new Runnable() { @Override public void run() { server.serve(); } }; serverThread = new Thread(st); serverThread.setDaemon(true); serverThread.start(); return addr; }
private void startMiniAccumulo() { try { // start mini accumulo cluster MiniAccumuloConfig cfg = new MiniAccumuloConfig(new File(config.getMiniDataDir()), PASSWORD); cluster = new MiniAccumuloCluster(cfg); cluster.start(); log.debug("Started MiniAccumulo(accumulo=" + cluster.getInstanceName() + " zk=" + cluster.getZooKeepers() + ")"); // configuration that must overridden config.setAccumuloInstance(cluster.getInstanceName()); config.setAccumuloUser(USER); config.setAccumuloPassword(PASSWORD); config.setAccumuloZookeepers(cluster.getZooKeepers()); config.setInstanceZookeepers(cluster.getZooKeepers() + "/fluo"); // configuration that only needs to be set if not by user if ((config.containsKey(FluoConfiguration.ACCUMULO_TABLE_PROP) == false) || config.getAccumuloTable().trim().isEmpty()) { config.setAccumuloTable("fluo"); } InitializationOptions opts = new InitializationOptions(); try (FluoAdmin admin = FluoFactory.newAdmin(config)) { admin.initialize(opts); } File miniProps = new File(clientPropsPath(config)); config.getClientConfiguration().save(miniProps); log.debug("Wrote MiniFluo client properties to {}", miniProps.getAbsolutePath()); } catch (Exception e) { throw new RuntimeException(e); } }
private void startMiniAccumulo() { try { // start mini accumulo cluster MiniAccumuloConfig cfg = new MiniAccumuloConfig(new File(config.getMiniDataDir()), PASSWORD); cluster = new MiniAccumuloCluster(cfg); cluster.start(); log.debug("Started MiniAccumulo(accumulo=" + cluster.getInstanceName() + " zk=" + cluster.getZooKeepers() + ")"); // configuration that must overridden config.setAccumuloInstance(cluster.getInstanceName()); config.setAccumuloUser(USER); config.setAccumuloPassword(PASSWORD); config.setAccumuloZookeepers(cluster.getZooKeepers()); config.setInstanceZookeepers(cluster.getZooKeepers() + "/fluo"); // configuration that only needs to be set if not by user if ((config.containsKey(FluoConfiguration.ACCUMULO_TABLE_PROP) == false) || config.getAccumuloTable().trim().isEmpty()) { config.setAccumuloTable("fluo"); } InitializationOptions opts = new InitializationOptions(); try (FluoAdmin admin = FluoFactory.newAdmin(config)) { admin.initialize(opts); } File miniProps = new File(clientPropsPath(config)); config.getClientConfiguration().save(miniProps); log.debug("Wrote MiniFluo client properties to {}", miniProps.getAbsolutePath()); } catch (Exception e) { throw new RuntimeException(e); } }