use of org.apache.accumulo.master.Master in project accumulo by apache.
the class ReplicationOperationsImplIT method getReplicationOperations.
/**
* Spoof out the Master so we can call the implementation without starting a full instance.
*/
private ReplicationOperationsImpl getReplicationOperations() throws Exception {
Master master = EasyMock.createMock(Master.class);
EasyMock.expect(master.getConnector()).andReturn(conn).anyTimes();
EasyMock.expect(master.getInstance()).andReturn(inst).anyTimes();
EasyMock.replay(master);
final MasterClientServiceHandler mcsh = new MasterClientServiceHandler(master) {
@Override
protected Table.ID getTableId(Instance inst, String tableName) throws ThriftTableOperationException {
try {
return Table.ID.of(conn.tableOperations().tableIdMap().get(tableName));
} catch (Exception e) {
throw new RuntimeException(e);
}
}
};
ClientContext context = new ClientContext(inst, new Credentials("root", new PasswordToken(ROOT_PASSWORD)), getClientConfig());
return new ReplicationOperationsImpl(context) {
@Override
protected boolean getMasterDrain(final TInfo tinfo, final TCredentials rpcCreds, final String tableName, final Set<String> wals) throws AccumuloException, AccumuloSecurityException, TableNotFoundException {
try {
return mcsh.drainReplicationTable(tinfo, rpcCreds, tableName, wals);
} catch (TException e) {
throw new RuntimeException(e);
}
}
};
}
use of org.apache.accumulo.master.Master in project accumulo by apache.
the class FateAdmin method main.
public static void main(String[] args) throws Exception {
Help opts = new Help();
JCommander jc = new JCommander(opts);
jc.setProgramName(FateAdmin.class.getName());
LinkedHashMap<String, TxOpts> txOpts = new LinkedHashMap<>(2);
txOpts.put("fail", new FailOpts());
txOpts.put("delete", new DeleteOpts());
for (Entry<String, TxOpts> entry : txOpts.entrySet()) {
jc.addCommand(entry.getKey(), entry.getValue());
}
jc.addCommand("print", new PrintOpts());
jc.parse(args);
if (opts.help || jc.getParsedCommand() == null) {
jc.usage();
System.exit(1);
}
System.err.printf("This tool has been deprecated%nFATE administration now available within 'accumulo shell'%n$ fate fail <txid>... | delete <txid>... | print [<txid>...]%n%n");
AdminUtil<Master> admin = new AdminUtil<>();
Instance instance = HdfsZooInstance.getInstance();
String path = ZooUtil.getRoot(instance) + Constants.ZFATE;
String masterPath = ZooUtil.getRoot(instance) + Constants.ZMASTER_LOCK;
IZooReaderWriter zk = ZooReaderWriter.getInstance();
ZooStore<Master> zs = new ZooStore<>(path, zk);
if (jc.getParsedCommand().equals("fail")) {
for (String txid : txOpts.get(jc.getParsedCommand()).txids) {
if (!admin.prepFail(zs, zk, masterPath, txid)) {
System.exit(1);
}
}
} else if (jc.getParsedCommand().equals("delete")) {
for (String txid : txOpts.get(jc.getParsedCommand()).txids) {
if (!admin.prepDelete(zs, zk, masterPath, txid)) {
System.exit(1);
}
admin.deleteLocks(zs, zk, ZooUtil.getRoot(instance) + Constants.ZTABLE_LOCKS, txid);
}
} else if (jc.getParsedCommand().equals("print")) {
admin.print(new ReadOnlyStore<>(zs), zk, ZooUtil.getRoot(instance) + Constants.ZTABLE_LOCKS);
}
}
use of org.apache.accumulo.master.Master in project accumulo by apache.
the class Metrics2ReplicationMetricsTest method testAddReplicationQueueTimeMetrics.
@Test
public void testAddReplicationQueueTimeMetrics() throws Exception {
Master master = EasyMock.createMock(Master.class);
MetricsSystem system = EasyMock.createMock(MetricsSystem.class);
VolumeManager fileSystem = EasyMock.createMock(VolumeManager.class);
ReplicationUtil util = EasyMock.createMock(ReplicationUtil.class);
MutableStat stat = EasyMock.createMock(MutableStat.class);
MutableQuantiles quantiles = EasyMock.createMock(MutableQuantiles.class);
Path path1 = new Path("hdfs://localhost:9000/accumulo/wal/file1");
Path path2 = new Path("hdfs://localhost:9000/accumulo/wal/file2");
// First call will initialize the map of paths to modification time
EasyMock.expect(util.getPendingReplicationPaths()).andReturn(ImmutableSet.of(path1, path2));
EasyMock.expect(master.getFileSystem()).andReturn(fileSystem);
EasyMock.expect(fileSystem.getFileStatus(path1)).andReturn(createStatus(100));
EasyMock.expect(master.getFileSystem()).andReturn(fileSystem);
EasyMock.expect(fileSystem.getFileStatus(path2)).andReturn(createStatus(200));
// Second call will recognize the missing path1 and add the latency stat
EasyMock.expect(util.getPendingReplicationPaths()).andReturn(ImmutableSet.of(path2));
// Expect a call to reset the min/max
stat.resetMinMax();
EasyMock.expectLastCall();
// Expect the calls of adding the stats
quantiles.add(currentTime - 100);
EasyMock.expectLastCall();
stat.add(currentTime - 100);
EasyMock.expectLastCall();
EasyMock.replay(master, system, fileSystem, util, stat, quantiles);
Metrics2ReplicationMetrics metrics = new TestMetrics2ReplicationMetrics(master, system);
// Inject our mock objects
replaceField(metrics, "replicationUtil", util);
replaceField(metrics, "replicationQueueTimeQuantiles", quantiles);
replaceField(metrics, "replicationQueueTimeStat", stat);
// Two calls to this will initialize the map and then add metrics
metrics.addReplicationQueueTimeMetrics();
metrics.addReplicationQueueTimeMetrics();
EasyMock.verify(master, system, fileSystem, util, stat, quantiles);
}
use of org.apache.accumulo.master.Master in project accumulo by apache.
the class ImportTableTest method testTabletDir.
@Test
public void testTabletDir() {
Master master = EasyMock.createMock(Master.class);
VolumeManager volumeManager = EasyMock.createMock(VolumeManager.class);
ImportedTableInfo iti = new ImportedTableInfo();
iti.tableId = Table.ID.of("5");
// Different volumes with different paths
String[] tableDirs = new String[] { "hdfs://nn1:8020/apps/accumulo1/tables", "hdfs://nn2:8020/applications/accumulo/tables" };
// This needs to be unique WRT the importtable command
String tabletDir = "/c-00000001";
EasyMock.expect(master.getFileSystem()).andReturn(volumeManager);
// Choose the 2nd element
VolumeChooserEnvironment chooserEnv = new VolumeChooserEnvironment(iti.tableId);
EasyMock.expect(volumeManager.choose(EasyMock.eq(chooserEnv), EasyMock.eq(tableDirs))).andReturn(tableDirs[1]);
EasyMock.replay(master, volumeManager);
PopulateMetadataTable pmt = new PopulateMetadataTable(iti);
Assert.assertEquals(tableDirs[1] + "/" + iti.tableId + "/" + tabletDir, pmt.getClonedTabletDir(master, tableDirs, tabletDir));
EasyMock.verify(master, volumeManager);
}
use of org.apache.accumulo.master.Master in project accumulo by apache.
the class ShutdownTServerTest method testSingleShutdown.
@Test
public void testSingleShutdown() throws Exception {
final TServerInstance tserver = EasyMock.createMock(TServerInstance.class);
final boolean force = false;
final ShutdownTServer op = new ShutdownTServer(tserver, force);
final Master master = EasyMock.createMock(Master.class);
final long tid = 1l;
final TServerConnection tserverCnxn = EasyMock.createMock(TServerConnection.class);
final TabletServerStatus status = new TabletServerStatus();
status.tableMap = new HashMap<>();
// Put in a table info record, don't care what
status.tableMap.put("a_table", new TableInfo());
master.shutdownTServer(tserver);
EasyMock.expectLastCall().once();
EasyMock.expect(master.onlineTabletServers()).andReturn(Collections.singleton(tserver));
EasyMock.expect(master.getConnection(tserver)).andReturn(tserverCnxn);
EasyMock.expect(tserverCnxn.getTableMap(false)).andReturn(status);
EasyMock.replay(tserver, tserverCnxn, master);
// FATE op is not ready
long wait = op.isReady(tid, master);
assertTrue("Expected wait to be greater than 0", wait > 0);
EasyMock.verify(tserver, tserverCnxn, master);
// Reset the mocks
EasyMock.reset(tserver, tserverCnxn, master);
// The same as above, but should not expect call shutdownTServer on master again
EasyMock.expect(master.onlineTabletServers()).andReturn(Collections.singleton(tserver));
EasyMock.expect(master.getConnection(tserver)).andReturn(tserverCnxn);
EasyMock.expect(tserverCnxn.getTableMap(false)).andReturn(status);
EasyMock.replay(tserver, tserverCnxn, master);
// FATE op is not ready
wait = op.isReady(tid, master);
assertTrue("Expected wait to be greater than 0", wait > 0);
EasyMock.verify(tserver, tserverCnxn, master);
}
Aggregations