use of org.apache.accumulo.manager.Manager in project accumulo by apache.
the class PrepBulkImport method checkForMerge.
private void checkForMerge(final long tid, final Manager manager) throws Exception {
VolumeManager fs = manager.getVolumeManager();
final Path bulkDir = new Path(bulkInfo.sourceDir);
int maxTablets = Integer.parseInt(manager.getContext().getTableConfiguration(bulkInfo.tableId).get(Property.TABLE_BULK_MAX_TABLETS));
try (LoadMappingIterator lmi = BulkSerialize.readLoadMapping(bulkDir.toString(), bulkInfo.tableId, fs::open)) {
TabletIterFactory tabletIterFactory = startRow -> TabletsMetadata.builder(manager.getContext()).forTable(bulkInfo.tableId).overlapping(startRow, null).checkConsistency().fetch(PREV_ROW).build().stream().map(TabletMetadata::getExtent).iterator();
sanityCheckLoadMapping(bulkInfo.tableId.canonical(), lmi, tabletIterFactory, maxTablets, tid);
}
}
use of org.apache.accumulo.manager.Manager in project accumulo by apache.
the class FateIT method testTransactionStatus.
@Test(timeout = 30000)
public void testTransactionStatus() throws Exception {
ZooReaderWriter zk = new ZooReaderWriter(szk.getConn(), 30000, "secret");
zk.mkdirs(ZK_ROOT + Constants.ZFATE);
zk.mkdirs(ZK_ROOT + Constants.ZTABLE_LOCKS);
zk.mkdirs(ZK_ROOT + Constants.ZNAMESPACES + "/" + NS.canonical());
zk.mkdirs(ZK_ROOT + Constants.ZTABLE_STATE + "/" + TID.canonical());
zk.mkdirs(ZK_ROOT + Constants.ZTABLES + "/" + TID.canonical());
ZooStore<Manager> zooStore = new ZooStore<Manager>(ZK_ROOT + Constants.ZFATE, zk);
final AgeOffStore<Manager> store = new AgeOffStore<Manager>(zooStore, 1000 * 60 * 60 * 8, System::currentTimeMillis);
Manager manager = createMock(Manager.class);
ServerContext sctx = createMock(ServerContext.class);
expect(manager.getContext()).andReturn(sctx).anyTimes();
expect(sctx.getZooKeeperRoot()).andReturn(ZK_ROOT).anyTimes();
expect(sctx.getZooReaderWriter()).andReturn(zk).anyTimes();
replay(manager, sctx);
Fate<Manager> fate = new Fate<Manager>(manager, store, TraceRepo::toLogString);
try {
ConfigurationCopy config = new ConfigurationCopy();
config.set(Property.GENERAL_SIMPLETIMER_THREADPOOL_SIZE, "2");
config.set(Property.MANAGER_FATE_THREADPOOL_SIZE, "1");
fate.startTransactionRunners(config);
// Wait for the transaction runner to be scheduled.
UtilWaitThread.sleep(3000);
callStarted = new CountDownLatch(1);
finishCall = new CountDownLatch(1);
long txid = fate.startTransaction();
assertEquals(TStatus.NEW, getTxStatus(zk, txid));
fate.seedTransaction(txid, new TestOperation(NS, TID), true, "Test Op");
assertEquals(TStatus.SUBMITTED, getTxStatus(zk, txid));
// wait for call() to be called
callStarted.await();
assertEquals(TStatus.IN_PROGRESS, getTxStatus(zk, txid));
// tell the op to exit the method
finishCall.countDown();
// Check that it transitions to SUCCESSFUL
TStatus s = getTxStatus(zk, txid);
while (s != TStatus.SUCCESSFUL) {
s = getTxStatus(zk, txid);
Thread.sleep(10);
}
// Check that it gets removed
boolean errorSeen = false;
while (!errorSeen) {
try {
s = getTxStatus(zk, txid);
Thread.sleep(10);
} catch (KeeperException e) {
if (e.code() == KeeperException.Code.NONODE) {
errorSeen = true;
} else {
fail("Unexpected error thrown: " + e.getMessage());
}
}
}
} finally {
fate.shutdown();
}
}
use of org.apache.accumulo.manager.Manager 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.manager.Manager in project accumulo by apache.
the class ManagerReplicationCoordinatorTest method randomServer.
@Test
public void randomServer() {
Manager manager = EasyMock.createMock(Manager.class);
ZooReader reader = EasyMock.createMock(ZooReader.class);
ServerContext context = EasyMock.createMock(ServerContext.class);
EasyMock.expect(context.getConfiguration()).andReturn(config).anyTimes();
EasyMock.expect(context.getInstanceID()).andReturn(InstanceId.of("1234")).anyTimes();
EasyMock.expect(context.getZooReaderWriter()).andReturn(null).anyTimes();
EasyMock.expect(manager.getContext()).andReturn(context);
EasyMock.expect(manager.getInstanceID()).andReturn(InstanceId.of("1234"));
EasyMock.replay(manager, context, reader);
ManagerReplicationCoordinator coordinator = new ManagerReplicationCoordinator(manager, reader);
TServerInstance inst1 = new TServerInstance(HostAndPort.fromParts("host1", 1234), "session");
assertEquals(inst1, coordinator.getRandomTServer(Collections.singleton(inst1), 0));
}
use of org.apache.accumulo.manager.Manager in project accumulo by apache.
the class ManagerReplicationCoordinatorTest method invalidOffset.
@Test
public void invalidOffset() {
Manager manager = EasyMock.createMock(Manager.class);
ServerContext context = EasyMock.createMock(ServerContext.class);
EasyMock.expect(context.getConfiguration()).andReturn(config).anyTimes();
EasyMock.expect(context.getInstanceID()).andReturn(InstanceId.of("1234")).anyTimes();
EasyMock.expect(context.getZooReaderWriter()).andReturn(null).anyTimes();
ZooReader reader = EasyMock.createMock(ZooReader.class);
EasyMock.expect(manager.getContext()).andReturn(context);
EasyMock.expect(manager.getInstanceID()).andReturn(InstanceId.of("1234"));
EasyMock.replay(manager, context, reader);
ManagerReplicationCoordinator coordinator = new ManagerReplicationCoordinator(manager, reader);
TServerInstance inst1 = new TServerInstance(HostAndPort.fromParts("host1", 1234), "session");
assertThrows(IllegalArgumentException.class, () -> coordinator.getRandomTServer(Collections.singleton(inst1), 1));
}
Aggregations