use of org.apache.accumulo.core.clientImpl.Writer in project accumulo by apache.
the class ReplicationTableUtil method getWriter.
static synchronized Writer getWriter(ClientContext context) {
Writer replicationTable = writers.get(context.getCredentials());
if (replicationTable == null) {
configureMetadataTable(context, MetadataTable.NAME);
replicationTable = new Writer(context, MetadataTable.ID);
writers.put(context.getCredentials(), replicationTable);
}
return replicationTable;
}
use of org.apache.accumulo.core.clientImpl.Writer in project accumulo by apache.
the class MetadataTableUtil method getRootTable.
public static synchronized Writer getRootTable(ServerContext context) {
Credentials credentials = context.getCredentials();
Writer rootTable = root_tables.get(credentials);
if (rootTable == null) {
rootTable = new Writer(context, RootTable.ID);
root_tables.put(credentials, rootTable);
}
return rootTable;
}
use of org.apache.accumulo.core.clientImpl.Writer in project accumulo by apache.
the class MetadataTableUtil method getMetadataTable.
public static synchronized Writer getMetadataTable(ServerContext context) {
Credentials credentials = context.getCredentials();
Writer metadataTable = metadata_tables.get(credentials);
if (metadataTable == null) {
metadataTable = new Writer(context, MetadataTable.ID);
metadata_tables.put(credentials, metadataTable);
}
return metadataTable;
}
use of org.apache.accumulo.core.clientImpl.Writer in project accumulo by apache.
the class MetaConstraintRetryIT method test.
// a test for ACCUMULO-3096
@Test
public void test() throws Exception {
try (AccumuloClient client = Accumulo.newClient().from(getClientProps()).build()) {
client.securityOperations().grantTablePermission(getAdminPrincipal(), MetadataTable.NAME, TablePermission.WRITE);
ServerContext context = getServerContext();
Writer w = new Writer(context, MetadataTable.ID);
KeyExtent extent = new KeyExtent(TableId.of("5"), null, null);
Mutation m = new Mutation(extent.toMetaRow());
// unknown columns should cause constraint violation
m.put("badcolfam", "badcolqual", "3");
var e = assertThrows(RuntimeException.class, () -> MetadataTableUtil.update(context, w, null, m, extent));
assertEquals(ConstraintViolationException.class, e.getCause().getClass());
}
}
use of org.apache.accumulo.core.clientImpl.Writer in project accumulo by apache.
the class ReplicationTableUtilTest method properPathInRow.
@Test
public void properPathInRow() throws Exception {
Writer writer = EasyMock.createNiceMock(Writer.class);
writer.update(EasyMock.anyObject(Mutation.class));
final List<Mutation> mutations = new ArrayList<>();
// Mock a Writer to just add the mutation to a list
EasyMock.expectLastCall().andAnswer(() -> {
mutations.add(((Mutation) EasyMock.getCurrentArguments()[0]));
return null;
});
EasyMock.replay(writer);
Credentials creds = new Credentials("root", new PasswordToken(""));
ClientContext context = EasyMock.createMock(ClientContext.class);
EasyMock.expect(context.getCredentials()).andReturn(creds).anyTimes();
EasyMock.replay(context);
// Magic hook to create a Writer
ReplicationTableUtil.addWriter(creds, writer);
// Example file seen coming out of LogEntry
UUID uuid = UUID.randomUUID();
String myFile = "file:////home/user/accumulo/wal/server+port/" + uuid;
long createdTime = System.currentTimeMillis();
ReplicationTableUtil.updateFiles(context, new KeyExtent(TableId.of("1"), null, null), myFile, StatusUtil.fileCreated(createdTime));
verify(writer);
assertEquals(1, mutations.size());
Mutation m = mutations.get(0);
assertEquals(ReplicationSection.getRowPrefix() + "file:/home/user/accumulo/wal/server+port/" + uuid, new Text(m.getRow()).toString());
List<ColumnUpdate> updates = m.getUpdates();
assertEquals(1, updates.size());
ColumnUpdate update = updates.get(0);
assertEquals(ReplicationSection.COLF, new Text(update.getColumnFamily()));
assertEquals("1", new Text(update.getColumnQualifier()).toString());
assertEquals(StatusUtil.fileCreatedValue(createdTime), new Value(update.getValue()));
}
Aggregations