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));
}
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"));
}
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);
}
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);
}
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);
}
Aggregations