protected TableOperations getTableOperations() { if (tops == null) try { tops = context.getConnector().tableOperations(); } catch (AccumuloException e) { log.error("Unable to access table operations from within table balancer", e); } catch (AccumuloSecurityException e) { log.error("Unable to access table operations from within table balancer", e); } return tops; }
public ClientServiceHandler(AccumuloServerContext context, TransactionWatcher transactionWatcher, VolumeManager fs) { this.context = context; this.instance = context.getInstance(); this.transactionWatcher = transactionWatcher; this.fs = fs; this.security = AuditedSecurityOperation.getInstance(context); }
@Override public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws Exception { List<String> tservers; MasterMonitorInfo stats; MasterClientService.Iface client = null; try { AccumuloServerContext context = new AccumuloServerContext( new ServerConfigurationFactory(shellState.getInstance())); client = MasterClient.getConnectionWithRetry(context); stats = client.getMasterStats(Tracer.traceInfo(), context.rpcCreds()); } finally { if (client != null) MasterClient.close(client); } final boolean paginate = !cl.hasOption(disablePaginationOpt.getOpt()); if (cl.hasOption(tserverOption.getOpt())) { tservers = new ArrayList<>(); tservers.add(cl.getOptionValue(tserverOption.getOpt())); } else { tservers = Collections.emptyList(); } shellState.printLines(new BulkImportListIterator(tservers, stats), paginate); return 0; }
@Override public SaslServerConnectionParams getSaslParams() { AccumuloConfiguration conf = getServerConfigurationFactory().getSiteConfiguration(); if (!conf.getBoolean(Property.INSTANCE_RPC_SASL_ENABLED)) { return null; } return new SaslServerConnectionParams(conf, getCredentials().getToken(), secretManager); }
@Override public Connector getConnector() throws AccumuloException, AccumuloSecurityException { // avoid making more connectors than necessary if (conn == null) { if (inst instanceof ZooKeeperInstance || inst instanceof HdfsZooInstance) { // reuse existing context conn = new ConnectorImpl(this); } else { Credentials c = getCredentials(); conn = getInstance().getConnector(c.getPrincipal(), c.getToken()); } } return conn; } }
public Set<ReplicationTarget> getReplicationTargets() { // The total set of configured targets final Set<ReplicationTarget> allConfiguredTargets = new HashSet<>(); final Map<String,String> tableNameToId = Tables.getNameToIdMap(context.getInstance()); for (String table : tableNameToId.keySet()) { if (MetadataTable.NAME.equals(table) || RootTable.NAME.equals(table)) { continue; } String localId = tableNameToId.get(table); if (null == localId) { log.trace("Could not determine ID for {}", table); continue; } TableConfiguration tableConf = context.getServerConfigurationFactory() .getTableConfiguration(localId); if (null == tableConf) { log.trace("Could not get configuration for table {} (it no longer exists)", table); continue; } for (Entry<String,String> prop : tableConf .getAllPropertiesWithPrefix(Property.TABLE_REPLICATION_TARGET).entrySet()) { String peerName = prop.getKey() .substring(Property.TABLE_REPLICATION_TARGET.getKey().length()); String remoteIdentifier = prop.getValue(); ReplicationTarget target = new ReplicationTarget(peerName, remoteIdentifier, localId); allConfiguredTargets.add(target); } } return allConfiguredTargets; }
public static void main(String[] args) throws Exception { Random random = new Random(System.currentTimeMillis() % 1000); int port = random.nextInt(30000) + 2000; AccumuloServerContext context = new AccumuloServerContext( new ServerConfigurationFactory(HdfsZooInstance.getInstance())); final ThriftClientHandler tch = new ThriftClientHandler(context, watcher); Processor<Iface> processor = new Processor<Iface>(tch); ServerAddress serverPort = TServerUtils.startTServer(context.getConfiguration(), ThriftServerType.CUSTOM_HS_HA, processor, "ZombieTServer", "walking dead", 2, 1, 1000, 10 * 1024 * 1024, null, null, -1, HostAndPort.fromParts("0.0.0.0", port)); String zPath = ZooUtil.getRoot(context.getInstance()) + Constants.ZTSERVERS + "/" + addressString; ZooReaderWriter zoo = ZooReaderWriter.getInstance();
@Override protected void pageBody(HttpServletRequest req, HttpServletResponse response, StringBuilder sb) throws Exception { final Connector conn = Monitor.getContext().getConnector(); final MasterMonitorInfo mmi = Monitor.getMmi(); String zkRoot = ZooUtil.getRoot(Monitor.getContext().getInstance()); final String workQueuePath = zkRoot + ReplicationConstants.ZOO_WORK_QUEUE; Monitor.getContext().getConfiguration());
protected static void fetchScans() throws Exception { if (instance == null) return; Connector c = context.getConnector(); for (String server : c.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(); } } }
/** * Initialize the TabletBalancer. This gives the balancer the opportunity to read the * configuration. */ public void init(ServerConfigurationFactory conf) { context = new AccumuloServerContext(conf); configuration = conf; }
/** * Retrieve the SSL/TLS configuration for starting up a listening service */ public SslConnectionParams getServerSslParams() { return SslConnectionParams.forServer(getConfiguration()); }
public static void main(String[] args) throws AccumuloException, AccumuloSecurityException { ClientOnRequiredTable opts = new ClientOnRequiredTable(); opts.parseArgs(RandomizeVolumes.class.getName(), args); Connector c; if (opts.getToken() == null) { AccumuloServerContext context = new AccumuloServerContext( new ServerConfigurationFactory(opts.getInstance())); c = context.getConnector(); } else { c = opts.getConnector(); } try { int status = randomize(c, opts.getTableName()); System.exit(status); } catch (Exception ex) { log.error("{}", ex.getMessage(), ex); System.exit(4); } }
private static void exportConfig(AccumuloServerContext context, String tableID, ZipOutputStream zipOut, DataOutputStream dataOut) throws AccumuloException, AccumuloSecurityException, TableNotFoundException, IOException { Connector conn = context.getConnector(); Map<String,String> systemConfig = conn.instanceOperations().getSystemConfiguration(); TableConfiguration tableConfig = context.getServerConfigurationFactory() .getTableConfiguration(tableID);
private static void initSecurity(AccumuloServerContext context, Opts opts, String iid, String rootUser) throws AccumuloSecurityException, ThriftSecurityException, IOException { AuditedSecurityOperation.getInstance(context, true).initializeSecurity(context.rpcCreds(), rootUser, opts.rootpass); }
Property timeBetweenThreadChecksProperty, Property maxMessageSizeProperty) throws UnknownHostException { final AccumuloConfiguration config = service.getConfiguration(); final ThriftServerType serverType = service.getThriftServerType(); return TServerUtils.startTServer(serverType, timedProcessor, serverName, threadName, minThreads, simpleTimerThreadpoolSize, timeBetweenThreadChecks, maxMessageSize, service.getServerSslParams(), service.getSaslParams(), service.getClientTimeoutInMillis(), addresses); } catch (TTransportException e) { return TServerUtils.startTServer(serverType, timedProcessor, serverName, threadName, minThreads, simpleTimerThreadpoolSize, timeBetweenThreadChecks, maxMessageSize, service.getServerSslParams(), service.getSaslParams(), service.getClientTimeoutInMillis(), addr); } catch (TTransportException tte) { log.info("Unable to use port {}, retrying. (Thread Name = {})", port, threadName);
gcStatus = label + " " + DateFormat.getInstance().format(new Date(start)); gcStatus = gcStatus.replace(" ", " "); long normalDelay = Monitor.getContext().getConfiguration() .getTimeInMillis(Property.GC_CYCLE_DELAY); if (diff > normalDelay * 2) slaves.add(down.server); List<String> masters = Monitor.getContext().getInstance().getMasterLocations();
AccumuloServerContext context = new AccumuloServerContext(new ServerConfigurationFactory(zki)); new AccumuloServerContext(new ServerConfigurationFactory(HdfsZooInstance.getInstance())), watcher); Processor<Iface> processor = new Processor<Iface>(tch); TServerUtils.startTServer(context.getConfiguration(), ThriftServerType.CUSTOM_HS_HA, processor, "NullTServer", "null tserver", 2, 1, 1000, 10 * 1024 * 1024, null, null, -1, HostAndPort.fromParts("0.0.0.0", opts.port));
ScanFileManager(KeyExtent tablet) { tabletReservedReaders = new ArrayList<>(); dataSources = new ArrayList<>(); this.tablet = tablet; continueOnFailure = context.getServerConfigurationFactory().getTableConfiguration(tablet) .getBoolean(Property.TABLE_FAILURES_IGNORE); if (tablet.isMeta()) { continueOnFailure = false; } }
public WalkingSecurity(State state2, Environment env2) { super(new AccumuloServerContext(new ServerConfigurationFactory(HdfsZooInstance.getInstance()))); this.state = state2; this.env = env2; authorizor = this; authenticator = this; permHandle = this; }
public int getMaxReplicationThreads(MasterMonitorInfo mmi) { int activeTservers = mmi.getTServerInfoSize(); // The number of threads each tserver will use at most to replicate data int replicationThreadsPerServer = Integer .parseInt(context.getConfiguration().get(Property.REPLICATION_WORKER_THREADS)); // The total number of "slots" we have to replicate data return activeTservers * replicationThreadsPerServer; }