use of org.apache.accumulo.minicluster.ServerType in project accumulo by apache.
the class StandaloneAccumuloClusterTest method test.
@Test
public void test() throws Exception {
StandaloneAccumuloCluster cluster = EasyMock.createMockBuilder(StandaloneAccumuloCluster.class).addMockedMethod("getClusterControl").createMock();
StandaloneClusterControl control = EasyMock.createMock(StandaloneClusterControl.class);
// Return our mocked clustercontrol
EasyMock.expect(cluster.getClusterControl()).andReturn(control);
// `SetGoalState NORMAL` should be called specifically on this method, not via ClusterControl.exec(..)
control.setGoalState(MasterGoalState.NORMAL.toString());
EasyMock.expectLastCall().once();
// Start the procs
for (ServerType type : StandaloneAccumuloCluster.ALL_SERVER_TYPES) {
control.startAllServers(type);
}
// Switch to replay
EasyMock.replay(cluster, control);
// Call start on the cluster
cluster.start();
// Verify the expectations
EasyMock.verify(cluster, control);
}
use of org.apache.accumulo.minicluster.ServerType in project accumulo by apache.
the class ExistingMacIT method testExistingInstance.
@Test
public void testExistingInstance() throws Exception {
Connector conn = getCluster().getConnector("root", new PasswordToken(ROOT_PASSWORD));
conn.tableOperations().create("table1");
BatchWriter bw = conn.createBatchWriter("table1", new BatchWriterConfig());
Mutation m1 = new Mutation("00081");
m1.put("math", "sqroot", "9");
m1.put("math", "sq", "6560");
bw.addMutation(m1);
bw.close();
conn.tableOperations().flush("table1", null, null, true);
// TOOD use constants
conn.tableOperations().flush(MetadataTable.NAME, null, null, true);
conn.tableOperations().flush(RootTable.NAME, null, null, true);
Set<Entry<ServerType, Collection<ProcessReference>>> procs = getCluster().getProcesses().entrySet();
for (Entry<ServerType, Collection<ProcessReference>> entry : procs) {
if (entry.getKey() == ServerType.ZOOKEEPER)
continue;
for (ProcessReference pr : entry.getValue()) getCluster().killProcess(entry.getKey(), pr);
}
final DefaultConfiguration defaultConfig = DefaultConfiguration.getInstance();
final long zkTimeout = ConfigurationTypeHelper.getTimeInMillis(getCluster().getConfig().getSiteConfig().get(Property.INSTANCE_ZK_TIMEOUT.getKey()));
IZooReaderWriter zrw = new ZooReaderWriterFactory().getZooReaderWriter(getCluster().getZooKeepers(), (int) zkTimeout, defaultConfig.get(Property.INSTANCE_SECRET));
final String zInstanceRoot = Constants.ZROOT + "/" + conn.getInstance().getInstanceID();
while (!AccumuloStatus.isAccumuloOffline(zrw, zInstanceRoot)) {
log.debug("Accumulo services still have their ZK locks held");
Thread.sleep(1000);
}
File hadoopConfDir = createTestDir(ExistingMacIT.class.getSimpleName() + "_hadoop_conf");
FileUtils.deleteQuietly(hadoopConfDir);
assertTrue(hadoopConfDir.mkdirs());
createEmptyConfig(new File(hadoopConfDir, "core-site.xml"));
createEmptyConfig(new File(hadoopConfDir, "hdfs-site.xml"));
File testDir2 = createTestDir(ExistingMacIT.class.getSimpleName() + "_2");
FileUtils.deleteQuietly(testDir2);
MiniAccumuloConfigImpl macConfig2 = new MiniAccumuloConfigImpl(testDir2, "notused");
macConfig2.useExistingInstance(new File(getCluster().getConfig().getConfDir(), "accumulo-site.xml"), hadoopConfDir);
MiniAccumuloClusterImpl accumulo2 = new MiniAccumuloClusterImpl(macConfig2);
accumulo2.start();
conn = accumulo2.getConnector("root", new PasswordToken(ROOT_PASSWORD));
try (Scanner scanner = conn.createScanner("table1", Authorizations.EMPTY)) {
int sum = 0;
for (Entry<Key, Value> entry : scanner) {
sum += Integer.parseInt(entry.getValue().toString());
}
Assert.assertEquals(6569, sum);
}
accumulo2.stop();
}
use of org.apache.accumulo.minicluster.ServerType in project accumulo by apache.
the class MiniAccumuloClusterImplTest method testAccurateProcessListReturned.
@Test(timeout = 10000)
public void testAccurateProcessListReturned() throws Exception {
Map<ServerType, Collection<ProcessReference>> procs = accumulo.getProcesses();
Assert.assertTrue(procs.containsKey(ServerType.GARBAGE_COLLECTOR));
for (ServerType t : new ServerType[] { ServerType.MASTER, ServerType.TABLET_SERVER, ServerType.ZOOKEEPER }) {
Assert.assertTrue(procs.containsKey(t));
Collection<ProcessReference> procRefs = procs.get(t);
Assert.assertTrue(1 <= procRefs.size());
for (ProcessReference procRef : procRefs) {
Assert.assertNotNull(procRef);
}
}
}
use of org.apache.accumulo.minicluster.ServerType in project accumulo by apache.
the class StandaloneAccumuloCluster method start.
@Override
public void start() throws IOException {
StandaloneClusterControl control = getClusterControl();
// TODO We can check the hosts files, but that requires us to be on a host with the installation. Limitation at the moment.
control.setGoalState(MasterGoalState.NORMAL.toString());
for (ServerType type : ALL_SERVER_TYPES) {
control.startAllServers(type);
}
}
Aggregations