Search in sources :

Example 1 with ActiveCompaction

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;
    }
}
Also used : ActiveCompaction(org.apache.accumulo.core.client.admin.ActiveCompaction) ArrayList(java.util.ArrayList) TableNotFoundException(org.apache.accumulo.core.client.TableNotFoundException) NamespaceNotFoundException(org.apache.accumulo.core.client.NamespaceNotFoundException) MutationsRejectedException(org.apache.accumulo.core.client.MutationsRejectedException) TableExistsException(org.apache.accumulo.core.client.TableExistsException) TException(org.apache.thrift.TException) NoMoreEntriesException(org.apache.accumulo.proxy.thrift.NoMoreEntriesException) ThriftTableOperationException(org.apache.accumulo.core.client.impl.thrift.ThriftTableOperationException) NamespaceExistsException(org.apache.accumulo.core.client.NamespaceExistsException) NamespaceNotEmptyException(org.apache.accumulo.core.client.NamespaceNotEmptyException) AccumuloSecurityException(org.apache.accumulo.core.client.AccumuloSecurityException) AccumuloException(org.apache.accumulo.core.client.AccumuloException) IteratorSetting(org.apache.accumulo.core.client.IteratorSetting) TabletId(org.apache.accumulo.core.data.TabletId)

Example 2 with ActiveCompaction

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();
}
Also used : ActiveCompaction(org.apache.accumulo.core.client.admin.ActiveCompaction) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) IteratorSetting(org.apache.accumulo.core.client.IteratorSetting) Map(java.util.Map) HashMap(java.util.HashMap)

Example 3 with ActiveCompaction

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);
    }
}
Also used : ActiveCompaction(org.apache.accumulo.core.client.admin.ActiveCompaction) TException(org.apache.thrift.TException) AccumuloException(org.apache.accumulo.core.client.AccumuloException) ArrayList(java.util.ArrayList) TTransportException(org.apache.thrift.transport.TTransportException) ThriftSecurityException(org.apache.accumulo.core.client.impl.thrift.ThriftSecurityException) HostAndPort(org.apache.accumulo.core.util.HostAndPort) AccumuloSecurityException(org.apache.accumulo.core.client.AccumuloSecurityException) Client(org.apache.accumulo.core.tabletserver.thrift.TabletClientService.Client)

Aggregations

ArrayList (java.util.ArrayList)3 ActiveCompaction (org.apache.accumulo.core.client.admin.ActiveCompaction)3 AccumuloException (org.apache.accumulo.core.client.AccumuloException)2 AccumuloSecurityException (org.apache.accumulo.core.client.AccumuloSecurityException)2 IteratorSetting (org.apache.accumulo.core.client.IteratorSetting)2 TException (org.apache.thrift.TException)2 HashMap (java.util.HashMap)1 Map (java.util.Map)1 MutationsRejectedException (org.apache.accumulo.core.client.MutationsRejectedException)1 NamespaceExistsException (org.apache.accumulo.core.client.NamespaceExistsException)1 NamespaceNotEmptyException (org.apache.accumulo.core.client.NamespaceNotEmptyException)1 NamespaceNotFoundException (org.apache.accumulo.core.client.NamespaceNotFoundException)1 TableExistsException (org.apache.accumulo.core.client.TableExistsException)1 TableNotFoundException (org.apache.accumulo.core.client.TableNotFoundException)1 ThriftSecurityException (org.apache.accumulo.core.client.impl.thrift.ThriftSecurityException)1 ThriftTableOperationException (org.apache.accumulo.core.client.impl.thrift.ThriftTableOperationException)1 TabletId (org.apache.accumulo.core.data.TabletId)1 Client (org.apache.accumulo.core.tabletserver.thrift.TabletClientService.Client)1 HostAndPort (org.apache.accumulo.core.util.HostAndPort)1 NoMoreEntriesException (org.apache.accumulo.proxy.thrift.NoMoreEntriesException)1