Search in sources :

Example 1 with ServerType

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);
}
Also used : ServerType(org.apache.accumulo.minicluster.ServerType) Test(org.junit.Test)

Example 2 with ServerType

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();
}
Also used : Connector(org.apache.accumulo.core.client.Connector) ServerType(org.apache.accumulo.minicluster.ServerType) Scanner(org.apache.accumulo.core.client.Scanner) ProcessReference(org.apache.accumulo.minicluster.impl.ProcessReference) DefaultConfiguration(org.apache.accumulo.core.conf.DefaultConfiguration) ZooReaderWriterFactory(org.apache.accumulo.server.zookeeper.ZooReaderWriterFactory) MiniAccumuloConfigImpl(org.apache.accumulo.minicluster.impl.MiniAccumuloConfigImpl) PasswordToken(org.apache.accumulo.core.client.security.tokens.PasswordToken) Entry(java.util.Map.Entry) IZooReaderWriter(org.apache.accumulo.fate.zookeeper.IZooReaderWriter) Value(org.apache.accumulo.core.data.Value) BatchWriterConfig(org.apache.accumulo.core.client.BatchWriterConfig) Collection(java.util.Collection) BatchWriter(org.apache.accumulo.core.client.BatchWriter) Mutation(org.apache.accumulo.core.data.Mutation) MiniAccumuloClusterImpl(org.apache.accumulo.minicluster.impl.MiniAccumuloClusterImpl) File(java.io.File) Key(org.apache.accumulo.core.data.Key) Test(org.junit.Test)

Example 3 with ServerType

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);
        }
    }
}
Also used : ServerType(org.apache.accumulo.minicluster.ServerType) Collection(java.util.Collection) Test(org.junit.Test)

Example 4 with ServerType

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);
    }
}
Also used : ServerType(org.apache.accumulo.minicluster.ServerType)

Aggregations

ServerType (org.apache.accumulo.minicluster.ServerType)4 Test (org.junit.Test)3 Collection (java.util.Collection)2 File (java.io.File)1 Entry (java.util.Map.Entry)1 BatchWriter (org.apache.accumulo.core.client.BatchWriter)1 BatchWriterConfig (org.apache.accumulo.core.client.BatchWriterConfig)1 Connector (org.apache.accumulo.core.client.Connector)1 Scanner (org.apache.accumulo.core.client.Scanner)1 PasswordToken (org.apache.accumulo.core.client.security.tokens.PasswordToken)1 DefaultConfiguration (org.apache.accumulo.core.conf.DefaultConfiguration)1 Key (org.apache.accumulo.core.data.Key)1 Mutation (org.apache.accumulo.core.data.Mutation)1 Value (org.apache.accumulo.core.data.Value)1 IZooReaderWriter (org.apache.accumulo.fate.zookeeper.IZooReaderWriter)1 MiniAccumuloClusterImpl (org.apache.accumulo.minicluster.impl.MiniAccumuloClusterImpl)1 MiniAccumuloConfigImpl (org.apache.accumulo.minicluster.impl.MiniAccumuloConfigImpl)1 ProcessReference (org.apache.accumulo.minicluster.impl.ProcessReference)1 ZooReaderWriterFactory (org.apache.accumulo.server.zookeeper.ZooReaderWriterFactory)1