@Override public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws Exception { List<String> tservers; final InstanceOperations instanceOps = shellState.getAccumuloClient().instanceOperations(); final boolean paginate = !cl.hasOption(disablePaginationOpt.getOpt()); if (cl.hasOption(tserverOption.getOpt())) { tservers = new ArrayList<>(); tservers.add(cl.getOptionValue(tserverOption.getOpt())); } else { tservers = instanceOps.getTabletServers(); } shellState.printLines(new ActiveScanIterator(tservers, instanceOps), paginate); return 0; }
@Override public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws Exception { List<String> tservers; final InstanceOperations instanceOps = shellState.getAccumuloClient().instanceOperations(); final boolean paginate = !cl.hasOption(disablePaginationOpt.getOpt()); if (cl.hasOption(tserverOption.getOpt())) { tservers = new ArrayList<>(); tservers.add(cl.getOptionValue(tserverOption.getOpt())); } else { tservers = instanceOps.getTabletServers(); } shellState.printLines(new PingIterator(tservers, instanceOps), paginate); return 0; }
@Override public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws Exception { List<String> tservers; String filterText = null; final InstanceOperations instanceOps = shellState.getAccumuloClient().instanceOperations(); final boolean paginate = !cl.hasOption(disablePaginationOpt.getOpt()); if (cl.hasOption(tserverOption.getOpt())) { tservers = new ArrayList<>(); tservers.add(cl.getOptionValue(tserverOption.getOpt())); } else { tservers = instanceOps.getTabletServers(); } if (cl.hasOption(filterOption.getOpt())) { filterText = ".*" + cl.getOptionValue(filterOption.getOpt()) + ".*"; } Iterator<String> activeCompactionIterator = new ActiveCompactionIterator(tservers, instanceOps); if (filterText != null) { String finalFilterText = filterText; activeCompactionIterator = Iterators.filter(activeCompactionIterator, t -> t.matches(finalFilterText)); } shellState.printLines(activeCompactionIterator, paginate); return 0; }
private static int ping(ClientContext context, List<String> args) { InstanceOperations io = context.instanceOperations(); if (args.size() == 0) { args = io.getTabletServers(); } int unreachable = 0; for (String tserver : args) { try { io.ping(tserver); System.out.println(tserver + " OK"); } catch (AccumuloException ae) { System.out.println(tserver + " FAILED (" + ae.getMessage() + ")"); unreachable++; } } System.out.printf("\n%d of %d tablet servers unreachable\n\n", unreachable, args.size()); return unreachable; }
public static void fetchScans() throws Exception { if (context == null) return; for (String server : context.instanceOperations().getTabletServers()) { final HostAndPort parsedServer = HostAndPort.fromString(server); Client tserver = ThriftUtil.getTServerClient(parsedServer, context); try { List<ActiveScan> scans = tserver.getActiveScans(null, context.rpcCreds()); synchronized (allScans) { allScans.put(parsedServer, new ScanStats(scans)); } } catch (Exception ex) { log.debug("Failed to get active scans from {}", server, ex); } finally { ThriftUtil.returnClient(tserver); } } // Age off old scan information Iterator<Entry<HostAndPort,ScanStats>> entryIter = allScans.entrySet().iterator(); long now = System.currentTimeMillis(); while (entryIter.hasNext()) { Entry<HostAndPort,ScanStats> entry = entryIter.next(); if (now - entry.getValue().fetched > 5 * 60 * 1000) { entryIter.remove(); } } }
tservers = ctx.instanceOperations().getTabletServers(); Collections.sort(tservers);
@Override public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws Exception { List<String> tservers; final InstanceOperations instanceOps = shellState.getConnector().instanceOperations(); final boolean paginate = !cl.hasOption(disablePaginationOpt.getOpt()); if (cl.hasOption(tserverOption.getOpt())) { tservers = new ArrayList<>(); tservers.add(cl.getOptionValue(tserverOption.getOpt())); } else { tservers = instanceOps.getTabletServers(); } shellState.printLines(new ActiveScanIterator(tservers, instanceOps), paginate); return 0; }
@Override public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws Exception { List<String> tservers; final InstanceOperations instanceOps = shellState.getConnector().instanceOperations(); final boolean paginate = !cl.hasOption(disablePaginationOpt.getOpt()); if (cl.hasOption(tserverOption.getOpt())) { tservers = new ArrayList<>(); tservers.add(cl.getOptionValue(tserverOption.getOpt())); } else { tservers = instanceOps.getTabletServers(); } shellState.printLines(new ActiveCompactionIterator(tservers, instanceOps), paginate); return 0; }
@Override public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws Exception { List<String> tservers; final InstanceOperations instanceOps = shellState.getConnector().instanceOperations(); final boolean paginate = !cl.hasOption(disablePaginationOpt.getOpt()); if (cl.hasOption(tserverOption.getOpt())) { tservers = new ArrayList<>(); tservers.add(cl.getOptionValue(tserverOption.getOpt())); } else { tservers = instanceOps.getTabletServers(); } shellState.printLines(new PingIterator(tservers, instanceOps), paginate); return 0; }
/** * Gets the TabletServers. * * @return A list of Strings of TabletServers. * @throws StoreException If failure. */ public List<String> getTabletServers() throws StoreException { return getConnection().instanceOperations().getTabletServers(); }
private static int ping(ClientContext context, List<String> args) throws AccumuloException, AccumuloSecurityException { InstanceOperations io = context.getConnector().instanceOperations(); if (args.size() == 0) { args = io.getTabletServers(); } int unreachable = 0; for (String tserver : args) { try { io.ping(tserver); System.out.println(tserver + " OK"); } catch (AccumuloException ae) { System.out.println(tserver + " FAILED (" + ae.getMessage() + ")"); unreachable++; } } System.out.printf("\n%d of %d tablet servers unreachable\n\n", unreachable, args.size()); return unreachable; }
static void runAdminStopTest(Connector c, MiniAccumuloClusterImpl cluster) throws InterruptedException, IOException { assertEquals(0, cluster.exec(TestIngest.class, "-i", cluster.getInstanceName(), "-z", cluster.getZooKeepers(), "-u", "root", "-p", ROOT_PASSWORD, "--createTable").waitFor()); List<String> tabletServers = c.instanceOperations().getTabletServers(); assertEquals(2, tabletServers.size()); String doomed = tabletServers.get(0); log.info("Stopping " + doomed); assertEquals(0, cluster.exec(Admin.class, "stop", doomed).waitFor()); tabletServers = c.instanceOperations().getTabletServers(); assertEquals(1, tabletServers.size()); assertFalse(tabletServers.get(0).equals(doomed)); }
public static boolean shouldQueueOperation(State state, Environment env) throws Exception { final ThreadPoolExecutor pool = (ThreadPoolExecutor) state.get("pool"); long queuedThreads = pool.getTaskCount() - pool.getActiveCount() - pool.getCompletedTaskCount(); final Connector conn = env.getConnector(); int numTservers = conn.instanceOperations().getTabletServers().size(); if (!shouldQueue(queuedThreads, numTservers)) { log.info("Not queueing because of " + queuedThreads + " outstanding tasks"); return false; } return true; }
@Override public List<String> getTabletServers(ByteBuffer login) throws TException { try { return getConnector(login).instanceOperations().getTabletServers(); } catch (Exception e) { throw new TException(e); } }
@Override public Set<TServerInstance> onlineTabletServers() { HashSet<TServerInstance> tservers = new HashSet<>(); for (String tserver : getConnector().instanceOperations().getTabletServers()) { try { String zPath = ZooUtil.getRoot(getConnector().getInstance()) + Constants.ZTSERVERS + "/" + tserver; long sessionId = ZooLock.getSessionId(new ZooCache(getCluster().getZooKeepers(), getConnector().getInstance().getZooKeepersSessionTimeOut()), zPath); tservers.add(new TServerInstance(tserver, sessionId)); } catch (Exception e) { throw new RuntimeException(e); } } return tservers; }
@Before public void setupTables() throws AccumuloException, AccumuloSecurityException, TableExistsException, TableNotFoundException { Connector conn = getConnector(); // Need at least two tservers Assume.assumeTrue("Not enough tservers to run test", conn.instanceOperations().getTabletServers().size() >= 2); // set up splits final SortedSet<Text> splits = new TreeSet<>(); for (int i = 0; i < NUM_SPLITS; i++) { splits.add(new Text(String.format("%08x", i * 1000))); } String[] names = getUniqueNames(2); UNUSED_TABLE = names[0]; TEST_TABLE = names[1]; // load into a table we won't use connector = getConnector(); connector.tableOperations().create(UNUSED_TABLE); connector.tableOperations().addSplits(UNUSED_TABLE, splits); // mark the table offline before it can rebalance. connector.tableOperations().offline(UNUSED_TABLE); // actual test table connector.tableOperations().create(TEST_TABLE); connector.tableOperations().setProperty(TEST_TABLE, Property.TABLE_SPLIT_THRESHOLD.getKey(), "10K"); }
@Override public void visit(State state, Environment env, Properties props) throws Exception { log.info("shutting down"); SetGoalState.main(new String[] {MasterGoalState.CLEAN_STOP.name()}); while (!env.getConnector().instanceOperations().getTabletServers().isEmpty()) { sleepUninterruptibly(1, TimeUnit.SECONDS); } while (true) { try { AccumuloServerContext context = new AccumuloServerContext( new ServerConfigurationFactory(HdfsZooInstance.getInstance())); Client client = MasterClient.getConnection(context); client.getMasterStats(Tracer.traceInfo(), context.rpcCreds()); } catch (Exception e) { // assume this is due to server shutdown break; } sleepUninterruptibly(1, TimeUnit.SECONDS); } log.info("servers stopped"); sleepUninterruptibly(10, TimeUnit.SECONDS); }
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; }
@Test(timeout = 2 * 60 * 1000) public void test() throws Exception { final Connector conn = this.getConnector(); // Yes, there's a tabletserver assertEquals(1, conn.instanceOperations().getTabletServers().size()); final String tableName = getUniqueNames(1)[0]; conn.tableOperations().create(tableName); BatchWriter bw = conn.createBatchWriter(tableName, null); for (int i = 0; i < N; i++) { Mutation m = new Mutation("" + i); m.put("", "", ""); bw.addMutation(m); } bw.close(); conn.tableOperations().flush(tableName, null, null, true); // Kill dfs cluster.getMiniDfs().restartNameNode(false); assertEquals(N, Iterators.size(conn.createScanner(tableName, Authorizations.EMPTY).iterator())); }
public SharedResources(Environment env) throws TableNotFoundException { this.env = env; curator = CuratorUtil.newAppCurator(env.getConfiguration()); curator.start(); int numTservers = env.getConnector().instanceOperations().getTabletServers().size(); int numBWThreads = FluoConfigurationImpl.getNumBWThreads(env.getConfiguration(), numTservers); bw = env.getConnector().createBatchWriter(env.getTable(), new BatchWriterConfig().setMaxWriteThreads(numBWThreads)); sbw = new SharedBatchWriter(bw); int numCWThreads = FluoConfigurationImpl.getNumCWThreads(env.getConfiguration(), numTservers); cw = env.getConnector().createConditionalWriter( env.getTable(), new ConditionalWriterConfig().setAuthorizations(env.getAuthorizations()) .setMaxWriteThreads(numCWThreads)); bulkCw = env.getConnector().createConditionalWriter( env.getTable(), new ConditionalWriterConfig().setAuthorizations(env.getAuthorizations()) .setMaxWriteThreads(numCWThreads)); txInfoCache = new TxInfoCache(env); visCache = new VisibilityCache(); metricRegistry = new MetricRegistry(); }