Search in sources :

Example 71 with AccumuloConfiguration

use of org.apache.accumulo.core.conf.AccumuloConfiguration in project accumulo by apache.

the class AccumuloReplicaSystemTest method testUserKeytab.

@Test
public void testUserKeytab() {
    AccumuloReplicaSystem ars = new AccumuloReplicaSystem();
    ReplicationTarget target = new ReplicationTarget("peer", "peer_table", TableId.of("1"));
    String user = "user", keytab = "/etc/security/keytabs/replication.keytab";
    Map<String, String> confMap = new HashMap<>();
    confMap.put(Property.REPLICATION_PEER_USER.getKey() + target.getPeerName(), user);
    confMap.put(Property.REPLICATION_PEER_KEYTAB.getKey() + target.getPeerName(), keytab);
    AccumuloConfiguration conf = new ConfigurationCopy(confMap);
    assertEquals(user, ars.getPrincipal(conf, target));
    assertEquals(keytab, ars.getKeytab(conf, target));
}
Also used : ConfigurationCopy(org.apache.accumulo.core.conf.ConfigurationCopy) ReplicationTarget(org.apache.accumulo.core.replication.ReplicationTarget) HashMap(java.util.HashMap) AccumuloConfiguration(org.apache.accumulo.core.conf.AccumuloConfiguration) Test(org.junit.Test)

Example 72 with AccumuloConfiguration

use of org.apache.accumulo.core.conf.AccumuloConfiguration in project accumulo by apache.

the class AccumuloReplicaSystemTest method mutationsNotReReplicatedToPeers.

@Test
public void mutationsNotReReplicatedToPeers() throws Exception {
    AccumuloReplicaSystem ars = new AccumuloReplicaSystem();
    Map<String, String> confMap = new HashMap<>();
    confMap.put(Property.REPLICATION_NAME.getKey(), "source");
    AccumuloConfiguration conf = new ConfigurationCopy(confMap);
    ars.setConf(conf);
    LogFileValue value = new LogFileValue();
    value.mutations = new ArrayList<>();
    Mutation m = new Mutation("row");
    m.put("", "", new Value());
    value.mutations.add(m);
    m = new Mutation("row2");
    m.put("", "", new Value());
    m.addReplicationSource("peer");
    value.mutations.add(m);
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    DataOutputStream out = new DataOutputStream(baos);
    // Replicate our 2 mutations to "peer", from tableid 1 to tableid 1
    ars.writeValueAvoidingReplicationCycles(out, value, new ReplicationTarget("peer", "1", TableId.of("1")));
    out.close();
    ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
    DataInputStream in = new DataInputStream(bais);
    int numMutations = in.readInt();
    assertEquals(1, numMutations);
    m = new Mutation();
    m.readFields(in);
    assertEquals("row", new String(m.getRow()));
    assertEquals(1, m.getReplicationSources().size());
    assertTrue("Expected source cluster to be listed in mutation replication source", m.getReplicationSources().contains("source"));
}
Also used : ConfigurationCopy(org.apache.accumulo.core.conf.ConfigurationCopy) HashMap(java.util.HashMap) DataOutputStream(java.io.DataOutputStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) DataInputStream(java.io.DataInputStream) ReplicationTarget(org.apache.accumulo.core.replication.ReplicationTarget) ByteArrayInputStream(java.io.ByteArrayInputStream) LogFileValue(org.apache.accumulo.tserver.logger.LogFileValue) Value(org.apache.accumulo.core.data.Value) LogFileValue(org.apache.accumulo.tserver.logger.LogFileValue) Mutation(org.apache.accumulo.core.data.Mutation) ServerMutation(org.apache.accumulo.server.data.ServerMutation) AccumuloConfiguration(org.apache.accumulo.core.conf.AccumuloConfiguration) Test(org.junit.Test)

Example 73 with AccumuloConfiguration

use of org.apache.accumulo.core.conf.AccumuloConfiguration in project accumulo by apache.

the class AccumuloReplicaSystemTest method endOfFileExceptionOnClosedWalImpliesFullyReplicated.

@Test
public void endOfFileExceptionOnClosedWalImpliesFullyReplicated() throws Exception {
    Map<String, String> confMap = new HashMap<>();
    confMap.put(Property.REPLICATION_NAME.getKey(), "source");
    AccumuloConfiguration conf = new ConfigurationCopy(confMap);
    AccumuloReplicaSystem ars = new AccumuloReplicaSystem();
    ars.setConf(conf);
    // Setting the file to be closed with the infinite end implies that we need to bump the begin up
    // to Long.MAX_VALUE
    // If it were still open, more data could be appended that we need to process
    Status status = Status.newBuilder().setBegin(100).setEnd(0).setInfiniteEnd(true).setClosed(true).build();
    DataInputStream dis = new DataInputStream(new ByteArrayInputStream(new byte[0]));
    WalReplication repl = ars.getWalEdits(new ReplicationTarget("peer", "1", TableId.of("1")), dis, new Path("/accumulo/wals/tserver+port/wal"), status, Long.MAX_VALUE, new HashSet<>());
    // We stopped because we got to the end of the file
    assertEquals(Long.MAX_VALUE, repl.entriesConsumed);
    assertEquals(0, repl.walEdits.getEditsSize());
    assertEquals(0, repl.sizeInRecords);
    assertEquals(0, repl.sizeInBytes);
}
Also used : Status(org.apache.accumulo.server.replication.proto.Replication.Status) Path(org.apache.hadoop.fs.Path) ConfigurationCopy(org.apache.accumulo.core.conf.ConfigurationCopy) HashMap(java.util.HashMap) DataInputStream(java.io.DataInputStream) ReplicationTarget(org.apache.accumulo.core.replication.ReplicationTarget) ByteArrayInputStream(java.io.ByteArrayInputStream) AccumuloConfiguration(org.apache.accumulo.core.conf.AccumuloConfiguration) Test(org.junit.Test)

Example 74 with AccumuloConfiguration

use of org.apache.accumulo.core.conf.AccumuloConfiguration in project accumulo by apache.

the class LargestFirstMemoryManagerTest method mockServerInfo.

@Before
public void mockServerInfo() {
    context = createMock(ServerContext.class);
    AccumuloConfiguration conf = createMock(AccumuloConfiguration.class);
    expect(context.getConfiguration()).andReturn(conf).anyTimes();
    expect(conf.getAsBytes(Property.TSERV_MAXMEM)).andReturn(ONE_GIG).anyTimes();
    expect(conf.getCount(Property.TSERV_MINC_MAXCONCURRENT)).andReturn(4).anyTimes();
    replay(context, conf);
}
Also used : ServerContext(org.apache.accumulo.server.ServerContext) AccumuloConfiguration(org.apache.accumulo.core.conf.AccumuloConfiguration) Before(org.junit.Before)

Example 75 with AccumuloConfiguration

use of org.apache.accumulo.core.conf.AccumuloConfiguration in project accumulo by apache.

the class CloseWriteAheadLogReferencesIT method setupEasyMockStuff.

@Before
public void setupEasyMockStuff() {
    SiteConfiguration siteConfig = EasyMock.createMock(SiteConfiguration.class);
    final AccumuloConfiguration systemConf = new ConfigurationCopy(new HashMap<>());
    // Just make the SiteConfiguration delegate to our AccumuloConfiguration
    // Presently, we only need get(Property) and iterator().
    EasyMock.expect(siteConfig.get(EasyMock.anyObject(Property.class))).andAnswer(() -> {
        Object[] args = EasyMock.getCurrentArguments();
        return systemConf.get((Property) args[0]);
    }).anyTimes();
    EasyMock.expect(siteConfig.getBoolean(EasyMock.anyObject(Property.class))).andAnswer(() -> {
        Object[] args = EasyMock.getCurrentArguments();
        return systemConf.getBoolean((Property) args[0]);
    }).anyTimes();
    EasyMock.expect(siteConfig.iterator()).andAnswer(systemConf::iterator).anyTimes();
    ServerContext context = createMock(ServerContext.class);
    expect(context.getProperties()).andReturn(new Properties()).anyTimes();
    expect(context.getZooKeepers()).andReturn("localhost").anyTimes();
    expect(context.getInstanceName()).andReturn("test").anyTimes();
    expect(context.getZooKeepersSessionTimeOut()).andReturn(30000).anyTimes();
    expect(context.getInstanceID()).andReturn(InstanceId.of("1111")).anyTimes();
    expect(context.getZooKeeperRoot()).andReturn(Constants.ZROOT + "/1111").anyTimes();
    replay(siteConfig, context);
    refs = new WrappedCloseWriteAheadLogReferences(context);
}
Also used : ConfigurationCopy(org.apache.accumulo.core.conf.ConfigurationCopy) ServerContext(org.apache.accumulo.server.ServerContext) SiteConfiguration(org.apache.accumulo.core.conf.SiteConfiguration) Properties(java.util.Properties) Property(org.apache.accumulo.core.conf.Property) AccumuloConfiguration(org.apache.accumulo.core.conf.AccumuloConfiguration) Before(org.junit.Before)

Aggregations

AccumuloConfiguration (org.apache.accumulo.core.conf.AccumuloConfiguration)164 Test (org.junit.Test)51 Path (org.apache.hadoop.fs.Path)44 IOException (java.io.IOException)31 ConfigurationCopy (org.apache.accumulo.core.conf.ConfigurationCopy)31 Configuration (org.apache.hadoop.conf.Configuration)27 HashMap (java.util.HashMap)24 ArrayList (java.util.ArrayList)23 Key (org.apache.accumulo.core.data.Key)23 FileSystem (org.apache.hadoop.fs.FileSystem)22 Value (org.apache.accumulo.core.data.Value)21 ServerContext (org.apache.accumulo.server.ServerContext)18 Property (org.apache.accumulo.core.conf.Property)16 DefaultConfiguration (org.apache.accumulo.core.conf.DefaultConfiguration)15 HostAndPort (org.apache.accumulo.core.util.HostAndPort)15 Map (java.util.Map)12 ByteArrayOutputStream (java.io.ByteArrayOutputStream)11 DataInputStream (java.io.DataInputStream)11 SamplerConfiguration (org.apache.accumulo.core.client.sample.SamplerConfiguration)11 SamplerConfigurationImpl (org.apache.accumulo.core.sample.impl.SamplerConfigurationImpl)11