public static synchronized DistributedQueryRunner createAccumuloQueryRunner(Map<String, String> extraProperties) throws Exception { DistributedQueryRunner queryRunner = new DistributedQueryRunner(createSession(), 4, extraProperties); queryRunner.installPlugin(new TpchPlugin()); queryRunner.createCatalog("tpch", "tpch"); queryRunner.installPlugin(new AccumuloPlugin()); Map<String, String> accumuloProperties = ImmutableMap.<String, String>builder() .put(AccumuloConfig.INSTANCE, connector.getInstance().getInstanceName()) .put(AccumuloConfig.ZOOKEEPERS, connector.getInstance().getZooKeepers()) .put(AccumuloConfig.USERNAME, MAC_USER) .put(AccumuloConfig.PASSWORD, MAC_PASSWORD) .put(AccumuloConfig.ZOOKEEPER_METADATA_ROOT, "/presto-accumulo-test") .build(); queryRunner.createCatalog("accumulo", "accumulo", accumuloProperties); if (!tpchLoaded) { copyTpchTables(queryRunner, "tpch", TINY_SCHEMA_NAME, createSession(), TpchTable.getTables()); connector.tableOperations().addSplits("tpch.orders", ImmutableSortedSet.of(new Text(new LexicoderRowSerializer().encode(BIGINT, 7500L)))); tpchLoaded = true; } return queryRunner; }
public TestAccumuloClient() throws Exception { AccumuloConfig config = new AccumuloConfig() .setUsername("root") .setPassword("secret"); Connector connector = AccumuloQueryRunner.getAccumuloConnector(); config.setZooKeepers(connector.getInstance().getZooKeepers()); zooKeeperMetadataManager = new ZooKeeperMetadataManager(config, new TypeRegistry()); client = new AccumuloClient(connector, config, zooKeeperMetadataManager, new AccumuloTableManager(connector), new IndexLookup(connector, new ColumnCardinalityCache(connector, config))); }
public static boolean isOnline(Connector conn) { return DeprecationUtil.isMockInstance(conn.getInstance()) || TableState.ONLINE == Tables.getTableState(conn.getInstance(), ID); }
@Override public boolean equals(Object obj) { if (obj instanceof AccumuloLoader) { AccumuloLoader loaderObj = AccumuloLoader.class.cast(obj); if (connector.getInstance().getInstanceID().equals(loaderObj.connector.getInstance().getInstanceID())) { if (tableName.equals(loaderObj.tableName)) return true; } } return false; }
@Override public String toString() { return new StringBuilder().append(instance.getInstanceID()).append("/").append(connector.getInstance().getInstanceName()).append("/").append("/") .append(table).append("/").append(user).toString(); }
private void checkOffline(Connector conn) throws Exception { if (Tables.getTableState(conn.getInstance(), tableInfo.tableID) != TableState.OFFLINE) { Tables.clearCache(conn.getInstance()); if (Tables.getTableState(conn.getInstance(), tableInfo.tableID) != TableState.OFFLINE) { throw new AcceptableThriftTableOperationException(tableInfo.tableID, tableInfo.tableName, TableOperation.EXPORT, TableOperationExceptionType.OTHER, "Table is not offline"); } } }
private void checkOffline(Connector conn) throws Exception { if (Tables.getTableState(conn.getInstance(), tableInfo.tableID) != TableState.OFFLINE) { Tables.clearCache(conn.getInstance()); if (Tables.getTableState(conn.getInstance(), tableInfo.tableID) != TableState.OFFLINE) { throw new ThriftTableOperationException(tableInfo.tableID, tableInfo.tableName, TableOperation.EXPORT, TableOperationExceptionType.OTHER, "Table is not offline"); } } }
private Map<String,Boolean> _getWals(Connector c) throws Exception { Map<String,Boolean> result = new HashMap<>(); Instance i = c.getInstance(); ZooReaderWriter zk = new ZooReaderWriter(i.getZooKeepers(), i.getZooKeepersSessionTimeOut(), ""); WalStateManager wals = new WalStateManager(c.getInstance(), zk); for (Entry<Path,WalState> entry : wals.getAllState().entrySet()) { // WALs are in use if they are not unreferenced result.put(entry.getKey().toString(), entry.getValue() != WalState.UNREFERENCED); } return result; }
public static IteratorSetting iteratorSetting(int priority, int sleepAfterFirstWrite, long batchWriterTimeout, long batchWriterMaxMemory, int numEntriesToWrite, String tableName, Connector connector, AuthenticationToken token, boolean clearCacheAfterFirstWrite, boolean splitAfterFirstWrite) { return iteratorSetting(priority, sleepAfterFirstWrite, batchWriterTimeout, batchWriterMaxMemory, numEntriesToWrite, tableName, connector.getInstance().getZooKeepers(), connector.getInstance().getInstanceName(), connector.getInstance().getZooKeepersSessionTimeOut(), connector.whoami(), token, clearCacheAfterFirstWrite, splitAfterFirstWrite); }
@Override public void run() { try { CacheTestReader.main(new String[] {pathName, testDir.getAbsolutePath(), getConnector().getInstance().getZooKeepers()}); } catch (Exception ex) { ref.set(ex); } } };
@Override public boolean apply(String tableId) { return Tables.getTableState(getConnector().getInstance(), tableId) == TableState.ONLINE; } });
public void printInfo() throws IOException { reader.print("\n" + SHELL_DESCRIPTION + "\n" + "- \n" + "- version: " + Constants.VERSION + "\n" + "- instance name: " + connector.getInstance().getInstanceName() + "\n" + "- instance id: " + connector.getInstance().getInstanceID() + "\n" + "- \n" + "- type 'help' for a list of available commands\n" + "- \n"); reader.flush(); }
/** * Initialize the DistributedWorkQueue using the proper ZK location */ protected void initializeWorkQueue(AccumuloConfiguration conf) { workQueue = new DistributedWorkQueue( ZooUtil.getRoot(conn.getInstance()) + ReplicationConstants.ZOO_WORK_QUEUE, conf); }
/** * Check authenticationToken works for this user. */ private void checkCredentials() { try { if (!connector.securityOperations().authenticateUser(connector.whoami(), authenticationToken)) throw new IllegalArgumentException("instance " + connector.getInstance().getInstanceName() + ": bad username " + connector.whoami() + " with token " + authenticationToken); } catch (AccumuloException | AccumuloSecurityException e) { throw new IllegalArgumentException("instance " + connector.getInstance().getInstanceName() + ": error with username " + connector.whoami() + " with token " + authenticationToken, e); } }
@Test(expected = RuntimeException.class) public void invalidInstanceName() throws Exception { final Connector conn = getConnector(); new ZooKeeperInstance("fake_instance_name", conn.getInstance().getZooKeepers()); }
@After public void checkForDanglingFateLocks() { FunctionalTestUtils.assertNoDanglingFateLocks(getConnector().getInstance(), getCluster()); }
private long getSyncs() throws Exception { Connector c = getConnector(); ServerConfigurationFactory confFactory = new ServerConfigurationFactory(c.getInstance()); AccumuloServerContext context = new AccumuloServerContext(confFactory); for (String address : c.instanceOperations().getTabletServers()) { TabletClientService.Client client = ThriftUtil .getTServerClient(HostAndPort.fromString(address), context); TabletServerStatus status = client.getTabletServerStatus(null, context.rpcCreds()); return status.syncs; } return 0; }
public MultiTableBatchWriter getMultiTableBatchWriter() { ClientContext context = new ClientContext(connector.getInstance(), new Credentials(getAdminPrincipal(), getAdminToken()), getCluster().getClientConfig()); return new MultiTableBatchWriterImpl(context, new BatchWriterConfig()); }
private TabletLocationState getTabletLocationState(Connector c, String tableId) throws FileNotFoundException, ConfigurationException { Credentials creds = new Credentials(getAdminPrincipal(), getAdminToken()); ClientContext context = new ClientContext(c.getInstance(), creds, getCluster().getClientConfig()); MetaDataTableScanner s = new MetaDataTableScanner(context, new Range(KeyExtent.getMetadataEntry(tableId, null))); TabletLocationState tlState = s.next(); s.close(); return tlState; } }
@Before public void configureInstance() throws Exception { conn = getConnector(); inst = conn.getInstance(); ReplicationTable.setOnline(conn); conn.securityOperations().grantTablePermission(conn.whoami(), MetadataTable.NAME, TablePermission.WRITE); conn.securityOperations().grantTablePermission(conn.whoami(), ReplicationTable.NAME, TablePermission.READ); conn.securityOperations().grantTablePermission(conn.whoami(), ReplicationTable.NAME, TablePermission.WRITE); }