final T object) {
final ByteArrayId id = getPrimaryId(object);
addObjectToCache(object);
try {
final Writer writer = accumuloOperations.createWriter(
getAccumuloTablename(),
true);
synchronized (this) {
if (!iteratorsAttached) {
iteratorsAttached = true;
final IteratorConfig[] configs = getIteratorConfig();
if ((configs != null) && (configs.length > 0)) {
accumuloOperations.attachIterators(
getAccumuloTablename(),
true,
configs);
}
}
}
final Mutation mutation = new Mutation(
new Text(
id.getBytes()));
final Text cf = getSafeText(getAccumuloColumnFamily());
final Text cq = getSafeText(getAccumuloColumnQualifier(object));
final byte[] visibility = getAccumuloVisibility(object);
if (visibility != null) {
mutation.put(
cf,
cq,
new ColumnVisibility(
visibility),
new Value(
PersistenceUtils.toBinary(object)));
}
else {
mutation.put(
cf,
cq,
new Value(
PersistenceUtils.toBinary(object)));
}
writer.write(mutation);
writer.close();
}
catch (final TableNotFoundException e) {
LOGGER.error(
"Unable add object",
e);