use of org.apache.accumulo.core.securityImpl.thrift.TCredentials in project accumulo by apache.
the class ReplicationOperationsImpl method drain.
@Override
public void drain(final String tableName, final Set<String> wals) throws AccumuloException, AccumuloSecurityException, TableNotFoundException {
requireNonNull(tableName);
final TInfo tinfo = TraceUtil.traceInfo();
final TCredentials rpcCreds = context.rpcCreds();
// Ask the manager if the table is fully replicated given these WALs, but don't poll inside the
// manager
boolean drained = false;
while (!drained) {
drained = getManagerDrain(tinfo, rpcCreds, tableName, wals);
if (!drained) {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new RuntimeException("Thread interrupted", e);
}
}
}
}
use of org.apache.accumulo.core.securityImpl.thrift.TCredentials in project accumulo by apache.
the class CredentialsTest method roundtripThrift.
@Test
public void roundtripThrift() {
var instanceID = InstanceId.of(testName());
Credentials creds = new Credentials("test", new PasswordToken("testing"));
TCredentials tCreds = creds.toThrift(instanceID);
Credentials roundtrip = Credentials.fromThrift(tCreds);
assertEquals(creds, roundtrip, "Round-trip through thrift changed credentials equality");
}
use of org.apache.accumulo.core.securityImpl.thrift.TCredentials 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);
}
}
};
}
use of org.apache.accumulo.core.securityImpl.thrift.TCredentials in project accumulo by apache.
the class AccumuloReplicaSystemTest method dontSendEmptyDataToPeer.
@Test
public void dontSendEmptyDataToPeer() throws Exception {
Client replClient = createMock(Client.class);
AccumuloReplicaSystem ars = createMock(AccumuloReplicaSystem.class);
WalEdits edits = new WalEdits(Collections.emptyList());
WalReplication walReplication = new WalReplication(edits, 0, 0, 0);
ReplicationTarget target = new ReplicationTarget("peer", "2", TableId.of("1"));
DataInputStream input = null;
Path p = new Path("/accumulo/wals/tserver+port/" + UUID.randomUUID());
Status status = null;
long sizeLimit = Long.MAX_VALUE;
String remoteTableId = target.getRemoteIdentifier();
TCredentials tcreds = null;
Set<Integer> tids = new HashSet<>();
WalClientExecReturn walClientExec = new WalClientExecReturn(ars, target, input, p, status, sizeLimit, remoteTableId, tcreds, tids);
expect(ars.getWalEdits(target, input, p, status, sizeLimit, tids)).andReturn(walReplication);
replay(replClient, ars);
ReplicationStats stats = walClientExec.execute(replClient);
verify(replClient, ars);
assertEquals(new ReplicationStats(0L, 0L, 0L), stats);
}
use of org.apache.accumulo.core.securityImpl.thrift.TCredentials in project accumulo by apache.
the class AccumuloReplicaSystemTest method consumedButNotSentDataShouldBeRecorded.
@Test
public void consumedButNotSentDataShouldBeRecorded() throws Exception {
Client replClient = createMock(Client.class);
AccumuloReplicaSystem ars = createMock(AccumuloReplicaSystem.class);
WalEdits edits = new WalEdits(Collections.emptyList());
WalReplication walReplication = new WalReplication(edits, 0, 5, 0);
ReplicationTarget target = new ReplicationTarget("peer", "2", TableId.of("1"));
DataInputStream input = null;
Path p = new Path("/accumulo/wals/tserver+port/" + UUID.randomUUID());
Status status = null;
long sizeLimit = Long.MAX_VALUE;
String remoteTableId = target.getRemoteIdentifier();
TCredentials tcreds = null;
Set<Integer> tids = new HashSet<>();
WalClientExecReturn walClientExec = new WalClientExecReturn(ars, target, input, p, status, sizeLimit, remoteTableId, tcreds, tids);
expect(ars.getWalEdits(target, input, p, status, sizeLimit, tids)).andReturn(walReplication);
replay(replClient, ars);
ReplicationStats stats = walClientExec.execute(replClient);
verify(replClient, ars);
assertEquals(new ReplicationStats(0L, 0L, 5L), stats);
}
Aggregations