Search in sources :

Example 1 with ManagerClientServiceHandler

use of org.apache.accumulo.manager.ManagerClientServiceHandler in project accumulo by apache.

the class ReplicationOperationsImplIT method getReplicationOperations.

/**
 * Spoof out the Manager so we can call the implementation without starting a full instance.
 */
private ReplicationOperationsImpl getReplicationOperations() {
    Manager manager = EasyMock.createMock(Manager.class);
    EasyMock.expect(manager.getContext()).andReturn(context).anyTimes();
    EasyMock.replay(manager);
    final ManagerClientServiceHandler mcsh = new ManagerClientServiceHandler(manager) {

        @Override
        protected TableId getTableId(ClientContext context, String tableName) {
            try {
                return TableId.of(client.tableOperations().tableIdMap().get(tableName));
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
        }
    };
    ClientContext context = (ClientContext) client;
    return new ReplicationOperationsImpl(context) {

        @Override
        protected boolean getManagerDrain(final TInfo tinfo, final TCredentials rpcCreds, final String tableName, final Set<String> wals) {
            try {
                return mcsh.drainReplicationTable(tinfo, rpcCreds, tableName, wals);
            } catch (TException e) {
                throw new RuntimeException(e);
            }
        }
    };
}
Also used : TInfo(org.apache.accumulo.core.trace.thrift.TInfo) TException(org.apache.thrift.TException) Set(java.util.Set) ManagerClientServiceHandler(org.apache.accumulo.manager.ManagerClientServiceHandler) TCredentials(org.apache.accumulo.core.securityImpl.thrift.TCredentials) ClientContext(org.apache.accumulo.core.clientImpl.ClientContext) Manager(org.apache.accumulo.manager.Manager) TException(org.apache.thrift.TException) ReplicationOperationsImpl(org.apache.accumulo.core.clientImpl.ReplicationOperationsImpl)

Aggregations

Set (java.util.Set)1 ClientContext (org.apache.accumulo.core.clientImpl.ClientContext)1 ReplicationOperationsImpl (org.apache.accumulo.core.clientImpl.ReplicationOperationsImpl)1 TCredentials (org.apache.accumulo.core.securityImpl.thrift.TCredentials)1 TInfo (org.apache.accumulo.core.trace.thrift.TInfo)1 Manager (org.apache.accumulo.manager.Manager)1 ManagerClientServiceHandler (org.apache.accumulo.manager.ManagerClientServiceHandler)1 TException (org.apache.thrift.TException)1