+ ", still removing from zookeeper if it's there."); shellState.getAccumuloClient().instanceOperations().removeProperty(property); Shell.log.debug("Successfully deleted system configuration option"); fullCommand.indexOf(property)); shellState.getAccumuloClient().instanceOperations().setProperty(property, value); Shell.log.debug("Successfully set system configuration option"); .putAll(shellState.getAccumuloClient().instanceOperations().getSystemConfiguration()); siteConfig.putAll(shellState.getAccumuloClient().instanceOperations().getSiteConfiguration()); .getSystemConfiguration().entrySet(); if (tableName != null) { acuconf = shellState.getAccumuloClient().tableOperations().getProperties(tableName);
@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; }
List<ActiveCompaction> acl = instanceOps.getActiveCompactions(tserver);
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; }
private static void exportConfig(ServerContext context, Table.ID tableID, ZipOutputStream zipOut, DataOutputStream dataOut) throws AccumuloException, AccumuloSecurityException, IOException { DefaultConfiguration defaultConfig = DefaultConfiguration.getInstance(); Map<String,String> siteConfig = context.instanceOperations().getSiteConfiguration(); Map<String,String> systemConfig = context.instanceOperations().getSystemConfiguration(); TableConfiguration tableConfig = context.getServerConfFactory().getTableConfiguration(tableID); OutputStreamWriter osw = new OutputStreamWriter(dataOut, UTF_8); // only put props that are different than defaults and higher level configurations zipOut.putNextEntry(new ZipEntry(Constants.EXPORT_TABLE_CONFIG_FILE)); for (Entry<String,String> prop : tableConfig) { if (prop.getKey().startsWith(Property.TABLE_PREFIX.getKey())) { Property key = Property.getPropertyByKey(prop.getKey()); if (key == null || !defaultConfig.get(key).equals(prop.getValue())) { if (!prop.getValue().equals(siteConfig.get(prop.getKey())) && !prop.getValue().equals(systemConfig.get(prop.getKey()))) { osw.append(prop.getKey() + "=" + prop.getValue() + "\n"); } } } } osw.flush(); } }
@Before public void reduceSessionIdle() throws Exception { InstanceOperations ops = getConnector().instanceOperations(); sessionIdle = ops.getSystemConfiguration().get(Property.TSERV_SESSION_MAXIDLE.getKey()); ops.setProperty(Property.TSERV_SESSION_MAXIDLE.getKey(), getMaxIdleTimeString()); log.info("Waiting for existing session idle time to expire"); Thread.sleep(AccumuloConfiguration.getTimeInMillis(sessionIdle)); log.info("Finished waiting"); }
private Path checkPath(String dir, String kind, String type) throws IOException, AccumuloException, AccumuloSecurityException { Path ret; Map<String,String> props = context.instanceOperations().getSystemConfiguration(); AccumuloConfiguration conf = new ConfigurationCopy(props); FileSystem fs = VolumeConfiguration.getVolume(dir, context.getHadoopConf(), conf) .getFileSystem(); if (dir.contains(":")) { ret = new Path(dir); } else { ret = fs.makeQualified(new Path(dir)); } try { if (!fs.getFileStatus(ret).isDirectory()) { throw new AccumuloException( kind + " import " + type + " directory " + dir + " is not a directory!"); } } catch (FileNotFoundException fnf) { throw new AccumuloException( kind + " import " + type + " directory " + dir + " does not exist!"); } if (type.equals("failure")) { FileStatus[] listStatus = fs.listStatus(ret); if (listStatus != null && listStatus.length != 0) { throw new AccumuloException("Bulk import failure directory " + ret + " is not empty"); } } return ret; }
@Override public void addPeer(final String name, final String replicaType) throws AccumuloException, AccumuloSecurityException { requireNonNull(name); requireNonNull(replicaType); context.instanceOperations().setProperty(Property.REPLICATION_PEERS.getKey() + name, replicaType); }
private void _verifySystemPropertyInheritance(String defaultNamespaceTable, String namespaceTable, String k, String v, boolean systemNamespaceShouldInherit) throws Exception { assertFalse(c.instanceOperations().getSystemConfiguration().containsValue(v)); assertFalse(checkNamespaceHasProp(Namespaces.ACCUMULO_NAMESPACE, k, v)); assertFalse(checkTableHasProp(RootTable.NAME, k, v)); c.instanceOperations().setProperty(k, v); assertTrue(c.instanceOperations().getSystemConfiguration().containsValue(v)); assertEquals(systemNamespaceShouldInherit, checkNamespaceHasProp(Namespaces.ACCUMULO_NAMESPACE, k, v)); c.instanceOperations().removeProperty(k); assertFalse(c.instanceOperations().getSystemConfiguration().containsValue(v)); assertFalse(checkNamespaceHasProp(Namespaces.ACCUMULO_NAMESPACE, k, v)); assertFalse(checkTableHasProp(RootTable.NAME, k, v));
@Override public void run() { try { // ensure the scan is running: not perfect, the metadata tables could be scanned, too. String tserver = conn.instanceOperations().getTabletServers().iterator().next(); do { ArrayList<ActiveScan> scans = new ArrayList<>( conn.instanceOperations().getActiveScans(tserver)); Iterator<ActiveScan> iter = scans.iterator(); while (iter.hasNext()) { ActiveScan scan = iter.next(); // Remove scans not against our table and not owned by us if (!getAdminPrincipal().equals(scan.getUser()) || !tableName.equals(scan.getTable())) { iter.remove(); } } if (!scans.isEmpty()) { // We found our scan break; } } while (true); } catch (Exception e) { e.printStackTrace(); } // BAM! scanThread.interrupt(); } };
List<String> tservers = connector.instanceOperations().getTabletServers(); runningCompactions += connector.instanceOperations().getActiveCompactions(tserver).size(); log.trace("tserver {}, running compactions {}", tservers, runningCompactions);
public OfflineIterator(ScannerOptions options, ClientContext context, Authorizations authorizations, Text table, Range range) { this.options = new ScannerOptions(options); this.context = context; this.range = range; if (this.options.fetchedColumns.size() > 0) { this.range = range.bound(this.options.fetchedColumns.first(), this.options.fetchedColumns.last()); } this.tableId = Table.ID.of(table.toString()); this.authorizations = authorizations; this.readers = new ArrayList<>(); try { config = new ConfigurationCopy(context.instanceOperations().getSiteConfiguration()); nextTablet(); while (iter != null && !iter.hasTop()) nextTablet(); } catch (Exception e) { if (e instanceof RuntimeException) throw (RuntimeException) e; throw new RuntimeException(e); } }
@Override public void removePeer(final String name) throws AccumuloException, AccumuloSecurityException { requireNonNull(name); context.instanceOperations().removeProperty(Property.REPLICATION_PEERS.getKey() + name); }
@Override public String next() { String tserver = iter.next(); try { instanceOps.ping(tserver); } catch (AccumuloException e) { return tserver + " ERROR " + e.getMessage(); } return tserver + " OK"; }
private void readNext() { final List<String> scans = new ArrayList<>(); while (tsIter.hasNext()) { final String tserver = tsIter.next(); try { final List<ActiveScan> asl = instanceOps.getActiveScans(tserver); for (ActiveScan as : asl) { scans.add(String.format( "%21s |%21s |%9s |%9s |%7s |%6s |%8s |%8s |%10s |%20s |%10s |%20s |%10s | %s", tserver, as.getClient(), Duration.format(as.getAge(), "", "-"), Duration.format(as.getLastContactTime(), "", "-"), as.getState(), as.getType(), as.getUser(), as.getTable(), as.getColumns(), as.getAuthorizations(), (as.getType() == ScanType.SINGLE ? as.getTablet() : "N/A"), as.getScanid(), as.getSsiList(), as.getSsio())); } } catch (Exception e) { scans.add(tserver + " ERROR " + e.getMessage()); } if (scans.size() > 0) { break; } } scansIter = scans.iterator(); }
@Before public void checkProperty() throws Exception { Connector conn = getConnector(); // TABLE_VOLUME_CHOOSER is a valid property that can be updated in ZK, whereas the crypto // properties are not. // This lets us run this test more generically rather than forcibly needing to update some // property in accumulo-site.xml origPropValue = conn.instanceOperations().getSystemConfiguration() .get(Property.TABLE_VOLUME_CHOOSER.getKey()); conn.instanceOperations().setProperty(Property.TABLE_VOLUME_CHOOSER.getKey(), FairVolumeChooser.class.getName()); }
siteConfig = context.instanceOperations().getSiteConfiguration(); systemConfig = context.instanceOperations().getSystemConfiguration(); if (opts.allConfiguration || opts.users) { localUsers = Lists.newArrayList(context.securityOperations().listLocalUsers());
@Override public void load() throws TableNotFoundException, IOException, AccumuloException, AccumuloSecurityException { Table.ID tableId = Tables.getTableId(context, tableName); Map<String,String> props = context.instanceOperations().getSystemConfiguration(); AccumuloConfiguration conf = new ConfigurationCopy(props); FileSystem fs = VolumeConfiguration.getVolume(dir, context.getHadoopConf(), conf) .getFileSystem(); Path srcPath = checkPath(fs, dir); SortedMap<KeyExtent,Bulk.Files> mappings; if (plan == null) { mappings = computeMappingFromFiles(fs, tableId, srcPath); } else { mappings = computeMappingFromPlan(fs, tableId, srcPath); } BulkSerialize.writeLoadMapping(mappings, srcPath.toString(), fs::create); List<ByteBuffer> args = Arrays.asList(ByteBuffer.wrap(tableId.getUtf8()), ByteBuffer.wrap(srcPath.toString().getBytes(UTF_8)), ByteBuffer.wrap((setTime + "").getBytes(UTF_8))); new TableOperationsImpl(context).doBulkFateOperation(args, tableName); }
@Override public void addPeer(final String name, final String replicaType) throws AccumuloException, AccumuloSecurityException, PeerExistsException { requireNonNull(name); requireNonNull(replicaType); context.getConnector().instanceOperations() .setProperty(Property.REPLICATION_PEERS.getKey() + name, replicaType); }
List<String> tservers = conn.instanceOperations().getTabletServers(); for (int i = 0; i < 10; i++) { try { activeScans = conn.instanceOperations().getActiveScans(tserver); break; } catch (AccumuloException e) {