@Override public void init() throws DBException { colFam = new Text(getProperties().getProperty("accumulo.columnFamily")); colFamBytes = colFam.toString().getBytes(UTF_8); inst = new ZooKeeperInstance(new ClientConfiguration() .withInstance(getProperties().getProperty("accumulo.instanceName")) .withZkHosts(getProperties().getProperty("accumulo.zooKeepers"))); try { String principal = getProperties().getProperty("accumulo.username"); AuthenticationToken token = new PasswordToken(getProperties().getProperty("accumulo.password")); connector = inst.getConnector(principal, token); } catch (AccumuloException | AccumuloSecurityException e) { throw new DBException(e); } if (!(getProperties().getProperty("accumulo.pcFlag", "none").equals("none"))) { System.err.println("Sorry, the ZK based producer/consumer implementation has been removed. " + "Please see YCSB issue #416 for work on adding a general solution to coordinated work."); } }
@Override public void init() throws DBException { colFam = new Text(getProperties().getProperty("accumulo.columnFamily")); colFamBytes = colFam.toString().getBytes(UTF_8); inst = new ZooKeeperInstance(new ClientConfiguration() .withInstance(getProperties().getProperty("accumulo.instanceName")) .withZkHosts(getProperties().getProperty("accumulo.zooKeepers"))); try { String principal = getProperties().getProperty("accumulo.username"); AuthenticationToken token = new PasswordToken(getProperties().getProperty("accumulo.password")); connector = inst.getConnector(principal, token); } catch (AccumuloException | AccumuloSecurityException e) { throw new DBException(e); } if (!(getProperties().getProperty("accumulo.pcFlag", "none").equals("none"))) { System.err.println("Sorry, the ZK based producer/consumer implementation has been removed. " + "Please see YCSB issue #416 for work on adding a general solution to coordinated work."); } }
/** * Initializes an empty configuration object to be further configured with other methods on the * class. * * @since 1.9.0 */ public static ClientConfiguration create() { return new ClientConfiguration(Collections.emptyList()); }
public static ClientConfiguration deserialize(String serializedConfig) { PropertiesConfiguration propConfig = new PropertiesConfiguration(); propConfig.setListDelimiter('\0'); try { propConfig.load(new StringReader(serializedConfig)); } catch (ConfigurationException e) { throw new IllegalArgumentException( "Error deserializing client configuration: " + serializedConfig, e); } return new ClientConfiguration(Collections.singletonList(propConfig)); }
@SuppressFBWarnings(value = "PATH_TRAVERSAL_IN", justification = "process runs in same security context as user who provided path") private static ClientConfiguration loadFromSearchPath(List<String> paths) { List<Configuration> configs = new LinkedList<>(); for (String path : paths) { File conf = new File(path); if (conf.isFile() && conf.canRead()) { PropertiesConfiguration props = new PropertiesConfiguration(); props.setListDelimiter('\0'); try { props.load(conf); log.info("Loaded client configuration file {}", conf); } catch (ConfigurationException e) { throw new IllegalStateException("Error loading client configuration file " + conf, e); } configs.add(props); } } // We couldn't find the client configuration anywhere if (configs.isEmpty()) { log.debug( "Found no client.conf in default paths. Using default client configuration values."); } return new ClientConfiguration(configs); }
/** * Initializes a configuration object from the contents of a map. The returned object can be * further configured with subsequent calls to other methods on this class. * * @param properties * a map containing the configuration properties to use * @since 1.9.0 */ public static ClientConfiguration fromMap(Map<String,String> properties) { MapConfiguration mapConf = new MapConfiguration(properties); mapConf.setListDelimiter('\0'); return new ClientConfiguration(Collections.singletonList(mapConf)); }
/** * Initializes a configuration object from the contents of a configuration file. Currently * supports Java "properties" files. The returned object can be further configured with subsequent * calls to other methods on this class. * * @param file * the path to the configuration file * @since 1.9.0 */ public static ClientConfiguration fromFile(File file) { PropertiesConfiguration props = new PropertiesConfiguration(); props.setListDelimiter('\0'); try { props.load(file); return new ClientConfiguration(Collections.singletonList(props)); } catch (ConfigurationException e) { throw new IllegalArgumentException("Bad configuration file: " + file, e); } }
/** * Initializes an empty configuration object to be further configured with other methods on the * class. * * @since 1.9.0 */ public static ClientConfiguration create() { return new ClientConfiguration(Collections.<Configuration> emptyList()); }
/** * Initializes a configuration object from the contents of a configuration file. Currently * supports Java "properties" files. The returned object can be further configured with subsequent * calls to other methods on this class. * * @param file * the path to the configuration file * @since 1.9.0 */ public static ClientConfiguration fromFile(File file) { try { return new ClientConfiguration(file); } catch (ConfigurationException e) { throw new IllegalArgumentException("Bad configuration file: " + file, e); } }
public static ClientConfiguration deserialize(String serializedConfig) { PropertiesConfiguration propConfig = new PropertiesConfiguration(); propConfig.setListDelimiter('\0'); try { propConfig.load(new StringReader(serializedConfig)); } catch (ConfigurationException e) { throw new IllegalArgumentException( "Error deserializing client configuration: " + serializedConfig, e); } return new ClientConfiguration(propConfig); }
/** * Initializes a configuration object from the contents of a map. The returned object can be * further configured with subsequent calls to other methods on this class. * * @param properties * a map containing the configuration properties to use * @since 1.9.0 */ public static ClientConfiguration fromMap(Map<String,String> properties) { MapConfiguration mapConf = new MapConfiguration(properties); mapConf.setListDelimiter('\0'); return new ClientConfiguration(Collections.singletonList(mapConf)); }
/** * Configures a {@link ZooKeeperInstance} for this job. * * @param job * the Hadoop job instance to be configured * @param instanceName * the Accumulo instance name * @param zooKeepers * a comma-separated list of zookeeper servers * @since 1.5.0 * @deprecated since 1.6.0; Use {@link #setZooKeeperInstance(Job, ClientConfiguration)} instead. */ @Deprecated public static void setZooKeeperInstance(Job job, String instanceName, String zooKeepers) { setZooKeeperInstance(job, new ClientConfiguration().withInstance(instanceName).withZkHosts(zooKeepers)); }
static Connector setupTXE1Connector(String txe1, AuthenticationToken auth) { String instanceName = txe1; String zookeeperHost = txe1+".cloud.llgrid.txe1.mit.edu:2181"; ClientConfiguration cc = new ClientConfiguration().withInstance(instanceName).withZkHosts(zookeeperHost);// .withZkTimeout(timeout) Instance instance = new ZooKeeperInstance(cc); try { return instance.getConnector("AccumuloUser", auth); } catch (AccumuloException | AccumuloSecurityException e) { throw new RuntimeException("Trouble authenticating to database "+txe1,e); } }
private static Connector getConnector(FluoConfiguration fluoConfig) throws Exception { ZooKeeperInstance zki = new ZooKeeperInstance( new ClientConfiguration().withInstance(fluoConfig.getAccumuloInstance()) .withZkHosts(fluoConfig.getAccumuloZookeepers())); Connector conn = zki.getConnector(fluoConfig.getAccumuloUser(), new PasswordToken(fluoConfig.getAccumuloPassword())); return conn; }
private static Connector getConnector(FluoConfiguration fluoConfig) throws Exception { ZooKeeperInstance zki = new ZooKeeperInstance(new ClientConfiguration().withInstance( fluoConfig.getAccumuloInstance()).withZkHosts(fluoConfig.getAccumuloZookeepers())); Connector conn = zki.getConnector(fluoConfig.getAccumuloUser(), new PasswordToken(fluoConfig.getAccumuloPassword())); return conn; }
ExportTask(String instanceName, String zookeepers, String user, String password, String table) throws TableNotFoundException, AccumuloException, AccumuloSecurityException { ZooKeeperInstance zki = new ZooKeeperInstance( new ClientConfiguration().withInstance(instanceName).withZkHosts(zookeepers)); // TODO need to close batch writer Connector conn = zki.getConnector(user, new PasswordToken(password)); try { bw = conn.createBatchWriter(table, new BatchWriterConfig()); } catch (TableNotFoundException tnfe) { try { conn.tableOperations().create(table); } catch (TableExistsException e) { // nothing to do } bw = conn.createBatchWriter(table, new BatchWriterConfig()); } }
/** * Creates Accumulo instance given FluoConfiguration */ public static Instance getInstance(FluoConfiguration config) { ClientConfiguration clientConfig = new ClientConfiguration() .withInstance(config.getAccumuloInstance()).withZkHosts(config.getAccumuloZookeepers()) .withZkTimeout(config.getZookeeperTimeout() / 1000); return new ZooKeeperInstance(clientConfig); }
/** * Creates Accumulo instance given FluoConfiguration */ public static Instance getInstance(FluoConfiguration config) { ClientConfiguration clientConfig = new ClientConfiguration().withInstance(config.getAccumuloInstance()) .withZkHosts(config.getAccumuloZookeepers()) .withZkTimeout(config.getZookeeperTimeout() / 1000); return new ZooKeeperInstance(clientConfig); }
protected void addZookeeperToConfiguration(final Configuration conf) { InputConfigurator.setZooKeeperInstance(AccumuloInputFormat.class, conf, new ClientConfiguration() .withInstance(getProperties().getInstance()) .withZkHosts(getProperties().getZookeepers())); }
private void initInstanceAndConnector(final Integer zkTimeout) throws AccumuloException, AccumuloSecurityException { clientConfiguration = new ClientConfiguration() .withInstance(INSTANCE_NAME) .withZkHosts("localhost:" + ZOOKEEPER_PORT); if (zkTimeout!=null && zkTimeout!=-1) { if (isZookeeperRunning("localhost:"+ZOOKEEPER_PORT,zkTimeout)) { instance = new ZooKeeperInstance(clientConfiguration); } } else { instance = new ZooKeeperInstance(clientConfiguration); } connector = instance.getConnector("root",new PasswordToken(ROOT_PASSWORD)); }