Refine search
@Override public void init() throws DBException { colFam = new Text(getProperties().getProperty("accumulo.columnFamily")); colFamBytes = colFam.toString().getBytes(UTF_8); inst = new ZooKeeperInstance( getProperties().getProperty("accumulo.instanceName"), 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 run() throws Exception { ZooKeeperInstance inst = new ZooKeeperInstance(mac.getClientConfig()); Connector conn = inst.getConnector(rootUgi.getUserName(), new KerberosToken()); conn.tableOperations().create(tableName); conn.securityOperations().createLocalUser(userWithoutCredentials1, new PasswordToken("ignored")); conn.securityOperations().grantTablePermission(userWithoutCredentials1, tableName, TablePermission.READ); conn.securityOperations().createLocalUser(userWithoutCredentials3, new PasswordToken("ignored")); conn.securityOperations().grantTablePermission(userWithoutCredentials3, tableName, TablePermission.READ); return null; } });
@Override public Connector get() { try { Instance inst = new ZooKeeperInstance(instance, zooKeepers); Connector connector = inst.getConnector(username, new PasswordToken(password.getBytes(UTF_8))); LOG.info("Connection to instance %s at %s established, user %s", instance, zooKeepers, username); return connector; } catch (AccumuloException | AccumuloSecurityException e) { throw new PrestoException(UNEXPECTED_ACCUMULO_ERROR, "Failed to get connector to Accumulo", e); } } }
instance = new MockInstance(config.get(ConfigUtils.CLOUDBASE_INSTANCE)); } else { instance = new ZooKeeperInstance(new ClientConfiguration().withInstance(instanceName).withZkHosts(zooKeepers)); final Connector connector = instance.getConnector(username, new PasswordToken(password)); final Authorizations auths = ConfigUtils.getAuthorizations(config); final Scanner scanner = connector.createScanner(tableName, auths); if (shouldAddCommonIterators) { AccumuloRyaUtils.addCommonScannerIteratorsTo(scanner);
protected void run(String[] args) throws ParseException, AccumuloSecurityException, AccumuloException, TableNotFoundException, IOException { parseConfig(args); ZooKeeperInstance instance = new ZooKeeperInstance(ClientConfiguration.loadDefault().withInstance(instanceName).withZkHosts(zookeepers)); Connector connector = instance.getConnector(username, new PasswordToken(password)); Authorizations auths = connector.securityOperations().getUserAuthorizations(connector.whoami()); BatchWriter writer = connector.createBatchWriter(tableName, new BatchWriterConfig().setMaxWriteThreads(bwThreads).setMaxMemory(bwMemory).setMaxLatency(60, TimeUnit.SECONDS)); BatchScanner scanner = connector.createBatchScanner(tableName, auths, bsThreads);
public FileDataQuery(String instanceName, String zooKeepers, String user, String password, String tableName, Authorizations auths) throws AccumuloException, AccumuloSecurityException, TableNotFoundException { ZooKeeperInstance instance = new ZooKeeperInstance(instanceName, zooKeepers); conn = instance.getConnector(user, password.getBytes()); lastRefs = new ArrayList<Entry<Key,Value>>(); cis = new ChunkInputStream(); scanner = conn.createScanner(tableName, auths); }
public static void main(String[] args) throws Exception { try (ConfigurableApplicationContext ctx = new SpringApplicationBuilder(SpringBootstrap.class) .bannerMode(Mode.OFF).web(false).run(args)) { Configuration conf = ctx.getBean(Configuration.class); final BaseConfiguration apacheConf = new BaseConfiguration(); Accumulo accumuloConf = conf.getAccumulo(); apacheConf.setProperty("instance.name", accumuloConf.getInstanceName()); apacheConf.setProperty("instance.zookeeper.host", accumuloConf.getZookeepers()); final ClientConfiguration aconf = new ClientConfiguration(Collections.singletonList(apacheConf)); final Instance instance = new ZooKeeperInstance(aconf); Connector con = instance.getConnector(accumuloConf.getUsername(), new PasswordToken(accumuloConf.getPassword())); Scanner s = con.createScanner(conf.getMetaTable(), con.securityOperations().getUserAuthorizations(con.whoami())); try { s.setRange(new Range(Meta.METRIC_PREFIX, true, Meta.TAG_PREFIX, false)); for (Entry<Key, Value> e : s) { System.out.println(e.getKey().getRow().toString().substring(Meta.METRIC_PREFIX.length())); } } finally { s.close(); } } } }
@Override protected void setup(Context context) throws IOException, InterruptedException { super.setup(context); Configuration conf = context.getConfiguration(); String user = conf.get(MetricsConfig.USER); String password = conf.get(MetricsConfig.PASS); String instance = conf.get(MetricsConfig.INSTANCE); String zookeepers = conf.get(MetricsConfig.ZOOKEEPERS); useHourlyPrecision = HourlyPrecisionHelper.checkForHourlyPrecisionOption(context.getConfiguration(), log); try { ZooKeeperInstance inst = new ZooKeeperInstance(ClientConfiguration.loadDefault().withInstance(instance).withZkHosts(zookeepers)); Connector con = inst.getConnector(user, new PasswordToken(password)); ingestScanner = con.createScanner(conf.get(MetricsConfig.INGEST_TABLE, MetricsConfig.DEFAULT_INGEST_TABLE), Authorizations.EMPTY); } catch (TableNotFoundException | AccumuloException | AccumuloSecurityException e) { throw new IOException(e); } }
final Instance instance = new ZooKeeperInstance(instanceName, zookeepers); connector = instance.getConnector(user, new PasswordToken(password)); } catch (final AccumuloException | AccumuloSecurityException e) { throw new RuntimeException("Exception connecting to Accumulo", e); final String tableId = connector.tableOperations().tableIdMap().get(tableName); final int numTablets = connector.tableOperations().listSplits(tableName).size() + 1; LOGGER.info("Table {} has id {} and {} tablets", tableName, tableId, numTablets);
@Override public void connect() throws IOException { Instance instance = null; instance = new ZooKeeperInstance(instanceName, zookeeperHost); try { PasswordToken t = new PasswordToken(password.getBytes()); connector = instance.getConnector(userName, t); } catch (AccumuloException e) { logger.error("error connecting to accumulo", e); DTThrowable.rethrow(e); } catch (AccumuloSecurityException e) { logger.error("error connecting to accumulo", e); DTThrowable.rethrow(e); } BatchWriterConfig config = new BatchWriterConfig(); config.setMaxMemory(memoryLimit); config.setMaxWriteThreads(numThreads); try { batchwriter = connector.createBatchWriter(tableName, config); } catch (TableNotFoundException e) { logger.error("table not found", e); DTThrowable.rethrow(e); } }
public OsmProvider(final OSMIngestCommandArgs args, final AccumuloRequiredOptions store) throws AccumuloSecurityException, AccumuloException, TableNotFoundException { conn = new ZooKeeperInstance(store.getInstance(), store.getZookeeper()).getConnector( store.getUser(), new PasswordToken(store.getPassword())); bs = conn.createBatchScanner( args.getQualifiedTableName(), new Authorizations(args.getVisibilityOptions().getVisibility()), 1); }
public static void main(String[] args) { if (args.length != 5) { System.err.println("Usage: accumulo accumulo.examples.client.Flush <instance name> <zoo keepers> <username> <password> <tableName>"); return; } String instanceName = args[0]; String zooKeepers = args[1]; String user = args[2]; String password = args[3]; String table = args[4]; Connector connector; try { ZooKeeperInstance instance = new ZooKeeperInstance(instanceName, zooKeepers); connector = instance.getConnector(user, password.getBytes()); connector.tableOperations().flush(table, null, null, true); } catch (Exception e) { throw new RuntimeException(e); } } }
/** * Initializes an Accumulo Instance based on the configuration. * * @param implementingClass * the class whose name will be used as a prefix for the property configuration key * @param conf * the Hadoop configuration object to configure * @return an Accumulo instance * @since 1.6.0 */ public static org.apache.accumulo.core.client.Instance getInstance(Class<?> implementingClass, Configuration conf) { String instanceType = conf.get(enumToConfKey(implementingClass, InstanceOpts.TYPE), ""); if ("ZooKeeperInstance".equals(instanceType)) { return new org.apache.accumulo.core.client.ZooKeeperInstance( getClientConfiguration(implementingClass, conf)); } else if (instanceType.isEmpty()) throw new IllegalStateException( "Instance has not been configured for " + implementingClass.getSimpleName()); else throw new IllegalStateException("Unrecognized instance type " + instanceType); }
iterations = Long.parseLong(args[7]); ZooKeeperInstance zki = new ZooKeeperInstance(instance, zooKeepers); Connector conn = zki.getConnector(user, pass.getBytes()); ArrayList<Text[]> randTerms = findRandomTerms(conn.createScanner(docTable, Constants.NO_AUTHS), numTerms); BatchScanner bs = conn.createBatchScanner(table, Constants.NO_AUTHS, 20);
/** * */ public AccumuloConnection(ConnectionProperties conn) throws AccumuloException,AccumuloSecurityException { this.conn = conn; ClientConfiguration cconfig = new ClientConfiguration().withInstance(conn.getInstanceName()).withZkHosts(conn.getHost()).withZkTimeout(conn.getSessionTimeOut()); this.instance = new ZooKeeperInstance(cconfig); principal = conn.getUser(); token = new PasswordToken(conn.getPass()); //principal = username = this.conn.getUser() //System.out.println("about to make connector: user="+this.conn.getUser()+" password="+ new String(this.passwordToken.getPassword())); this.connector = this.instance.getConnector(this.conn.getUser(), token); //System.out.println("made connector"); String [] sAuth = conn.getAuthorizations(); if (sAuth != null && sAuth.length > 0) { this.auth = new Authorizations(sAuth); } else { this.auth= Authorizations.EMPTY; } if (log.isDebugEnabled()) log.debug("!!!WHOAMI="+this.connector.whoami()); }
public QueryUtil(String instanceName, String zooKeepers, String user, String password, String tableName, Authorizations auths) throws AccumuloException, AccumuloSecurityException { ZooKeeperInstance instance = new ZooKeeperInstance(instanceName, zooKeepers); conn = instance.getConnector(user, password.getBytes()); this.tableName = tableName; this.auths = auths; }
String tableName = args[4]; ZooKeeperInstance instance = new ZooKeeperInstance(instanceName, zooKeepers); Connector connector = instance.getConnector(user, pass); MultiTableBatchWriter mtbw = connector.createMultiTableBatchWriter(200000l, 300, 4); if (!connector.tableOperations().exists(tableName)) connector.tableOperations().create(tableName); bw = mtbw.getBatchWriter(tableName);
private static BatchWriter setupBatchWriter(String instance, String zooKeepers, String table, String user, String pass) throws Exception { ZooKeeperInstance zinstance = new ZooKeeperInstance(instance, zooKeepers); Connector conn = zinstance.getConnector(user, pass.getBytes()); return conn.createBatchWriter(table, 50000000, 300000l, 4); }
@Override @Deprecated public Connector getConnector(String principal, byte[] pass) throws AccumuloException, AccumuloSecurityException { return getConnector(principal, new PasswordToken(pass)); }
int numRows = Integer.parseInt(args[6]); Instance instance = new ZooKeeperInstance(instanceName, zooKeepers); Connector connector = instance.getConnector(user, pass); Scanner scanner = connector.createScanner(table, Constants.NO_AUTHS);