use of org.apache.accumulo.core.client.admin.ActiveCompaction in project accumulo by apache.
the class ProxyServer method getActiveCompactions.
@Override
public List<org.apache.accumulo.proxy.thrift.ActiveCompaction> getActiveCompactions(ByteBuffer login, String tserver) throws org.apache.accumulo.proxy.thrift.AccumuloException, org.apache.accumulo.proxy.thrift.AccumuloSecurityException, TException {
try {
List<org.apache.accumulo.proxy.thrift.ActiveCompaction> result = new ArrayList<>();
List<ActiveCompaction> active = getConnector(login).instanceOperations().getActiveCompactions(tserver);
for (ActiveCompaction comp : active) {
org.apache.accumulo.proxy.thrift.ActiveCompaction pcomp = new org.apache.accumulo.proxy.thrift.ActiveCompaction();
pcomp.age = comp.getAge();
pcomp.entriesRead = comp.getEntriesRead();
pcomp.entriesWritten = comp.getEntriesWritten();
TabletId e = comp.getTablet();
pcomp.extent = new org.apache.accumulo.proxy.thrift.KeyExtent(e.getTableId().toString(), TextUtil.getByteBuffer(e.getEndRow()), TextUtil.getByteBuffer(e.getPrevEndRow()));
pcomp.inputFiles = new ArrayList<>();
if (comp.getInputFiles() != null) {
pcomp.inputFiles.addAll(comp.getInputFiles());
}
pcomp.localityGroup = comp.getLocalityGroup();
pcomp.outputFile = comp.getOutputFile();
pcomp.reason = CompactionReason.valueOf(comp.getReason().toString());
pcomp.type = CompactionType.valueOf(comp.getType().toString());
pcomp.iterators = new ArrayList<>();
if (comp.getIterators() != null) {
for (IteratorSetting setting : comp.getIterators()) {
org.apache.accumulo.proxy.thrift.IteratorSetting psetting = new org.apache.accumulo.proxy.thrift.IteratorSetting(setting.getPriority(), setting.getName(), setting.getIteratorClass(), setting.getOptions());
pcomp.iterators.add(psetting);
}
}
result.add(pcomp);
}
return result;
} catch (Exception e) {
handleException(e);
return null;
}
}
use of org.apache.accumulo.core.client.admin.ActiveCompaction in project accumulo by apache.
the class ActiveCompactionIterator method readNext.
private void readNext() {
final List<String> compactions = new ArrayList<>();
while (tsIter.hasNext()) {
final String tserver = tsIter.next();
try {
List<ActiveCompaction> acl = instanceOps.getActiveCompactions(tserver);
acl = new ArrayList<>(acl);
Collections.sort(acl, new Comparator<ActiveCompaction>() {
@Override
public int compare(ActiveCompaction o1, ActiveCompaction o2) {
return (int) (o2.getAge() - o1.getAge());
}
});
for (ActiveCompaction ac : acl) {
String output = ac.getOutputFile();
int index = output.indexOf("tables");
if (index > 0) {
output = output.substring(index + 6);
}
ac.getIterators();
List<String> iterList = new ArrayList<>();
Map<String, Map<String, String>> iterOpts = new HashMap<>();
for (IteratorSetting is : ac.getIterators()) {
iterList.add(is.getName() + "=" + is.getPriority() + "," + is.getIteratorClass());
iterOpts.put(is.getName(), is.getOptions());
}
compactions.add(String.format("%21s | %9s | %5s | %6s | %5s | %5s | %15s | %-40s | %5s | %35s | %9s | %s", tserver, Duration.format(ac.getAge(), "", "-"), ac.getType(), ac.getReason(), shortenCount(ac.getEntriesRead()), shortenCount(ac.getEntriesWritten()), ac.getTable(), ac.getTablet(), ac.getInputFiles().size(), output, iterList, iterOpts));
}
} catch (Exception e) {
compactions.add(tserver + " ERROR " + e.getMessage());
}
if (compactions.size() > 0) {
break;
}
}
compactionIter = compactions.iterator();
}
use of org.apache.accumulo.core.client.admin.ActiveCompaction in project accumulo by apache.
the class InstanceOperationsImpl method getActiveCompactions.
@Override
public List<ActiveCompaction> getActiveCompactions(String tserver) throws AccumuloException, AccumuloSecurityException {
final HostAndPort parsedTserver = HostAndPort.fromString(tserver);
Client client = null;
try {
client = ThriftUtil.getTServerClient(parsedTserver, context);
List<ActiveCompaction> as = new ArrayList<>();
for (org.apache.accumulo.core.tabletserver.thrift.ActiveCompaction activeCompaction : client.getActiveCompactions(Tracer.traceInfo(), context.rpcCreds())) {
as.add(new ActiveCompactionImpl(context.getInstance(), activeCompaction));
}
return as;
} catch (TTransportException e) {
throw new AccumuloException(e);
} catch (ThriftSecurityException e) {
throw new AccumuloSecurityException(e.user, e.code, e);
} catch (TException e) {
throw new AccumuloException(e);
} finally {
if (client != null)
ThriftUtil.returnClient(client);
}
}
Aggregations