use of org.apache.accumulo.core.client.MutationsRejectedException in project incubator-rya by apache.
the class AccumuloRyaInstanceDetailsRepository method initialize.
@Override
public void initialize(final RyaDetails details) throws AlreadyInitializedException, RyaDetailsRepositoryException {
// Preconditions.
requireNonNull(details);
if (!details.getRyaInstanceName().equals(instanceName)) {
throw new RyaDetailsRepositoryException("The instance name that was in the provided 'details' does not match " + "the instance name that this repository is connected to. Make sure you're connected to the" + "correct Rya instance.");
}
if (isInitialized()) {
throw new AlreadyInitializedException("The repository has already been initialized for the Rya instance named '" + instanceName + "'.");
}
// Create the table that hosts the details if it has not been created yet.
final TableOperations tableOps = connector.tableOperations();
if (!tableOps.exists(detailsTableName)) {
try {
tableOps.create(detailsTableName);
} catch (AccumuloException | AccumuloSecurityException | TableExistsException e) {
throw new RyaDetailsRepositoryException("Could not initialize the Rya instance details for the instance named '" + instanceName + "' because the the table that holds that information could not be created.");
}
}
// Write the details to the table.
BatchWriter writer = null;
try {
writer = connector.createBatchWriter(detailsTableName, new BatchWriterConfig());
final byte[] bytes = serializer.serialize(details);
final Mutation mutation = new Mutation(ROW_ID);
mutation.put(COL_FAMILY, COL_QUALIFIER, new Value(bytes));
writer.addMutation(mutation);
} catch (final TableNotFoundException | MutationsRejectedException e) {
throw new RyaDetailsRepositoryException("Could not initialize the Rya instance details for the instance named '" + instanceName + "'.", e);
} finally {
if (writer != null) {
try {
writer.close();
} catch (final MutationsRejectedException e) {
throw new RyaDetailsRepositoryException("Could not initialize the Rya instance details for the instance named '" + instanceName + "'.", e);
}
}
}
}
use of org.apache.accumulo.core.client.MutationsRejectedException in project accumulo by apache.
the class MetaDataStateStore method setLocations.
@Override
public void setLocations(Collection<Assignment> assignments) throws DistributedStoreException {
BatchWriter writer = createBatchWriter();
try {
for (Assignment assignment : assignments) {
Mutation m = new Mutation(assignment.tablet.getMetadataEntry());
assignment.server.putLocation(m);
assignment.server.clearFutureLocation(m);
SuspendingTServer.clearSuspension(m);
writer.addMutation(m);
}
} catch (Exception ex) {
throw new DistributedStoreException(ex);
} finally {
try {
writer.close();
} catch (MutationsRejectedException e) {
throw new DistributedStoreException(e);
}
}
}
use of org.apache.accumulo.core.client.MutationsRejectedException in project accumulo by apache.
the class MetaDataStateStore method suspend.
@Override
public void suspend(Collection<TabletLocationState> tablets, Map<TServerInstance, List<Path>> logsForDeadServers, long suspensionTimestamp) throws DistributedStoreException {
BatchWriter writer = createBatchWriter();
try {
for (TabletLocationState tls : tablets) {
Mutation m = new Mutation(tls.extent.getMetadataEntry());
if (tls.current != null) {
tls.current.clearLocation(m);
if (logsForDeadServers != null) {
List<Path> logs = logsForDeadServers.get(tls.current);
if (logs != null) {
for (Path log : logs) {
LogEntry entry = new LogEntry(tls.extent, 0, tls.current.hostPort(), log.toString());
m.put(entry.getColumnFamily(), entry.getColumnQualifier(), entry.getValue());
}
}
}
if (suspensionTimestamp >= 0) {
SuspendingTServer suspender = new SuspendingTServer(tls.current.getLocation(), suspensionTimestamp);
suspender.setSuspension(m);
}
}
if (tls.suspend != null && suspensionTimestamp < 0) {
SuspendingTServer.clearSuspension(m);
}
if (tls.future != null) {
tls.future.clearFutureLocation(m);
}
writer.addMutation(m);
}
} catch (Exception ex) {
throw new DistributedStoreException(ex);
} finally {
try {
writer.close();
} catch (MutationsRejectedException e) {
throw new DistributedStoreException(e);
}
}
}
use of org.apache.accumulo.core.client.MutationsRejectedException in project accumulo by apache.
the class MetaDataStateStore method unsuspend.
@Override
public void unsuspend(Collection<TabletLocationState> tablets) throws DistributedStoreException {
BatchWriter writer = createBatchWriter();
try {
for (TabletLocationState tls : tablets) {
if (tls.suspend != null) {
continue;
}
Mutation m = new Mutation(tls.extent.getMetadataEntry());
SuspendingTServer.clearSuspension(m);
writer.addMutation(m);
}
} catch (Exception ex) {
throw new DistributedStoreException(ex);
} finally {
try {
writer.close();
} catch (MutationsRejectedException e) {
throw new DistributedStoreException(e);
}
}
}
use of org.apache.accumulo.core.client.MutationsRejectedException in project accumulo by apache.
the class MetaDataStateStore method setFutureLocations.
@Override
public void setFutureLocations(Collection<Assignment> assignments) throws DistributedStoreException {
BatchWriter writer = createBatchWriter();
try {
for (Assignment assignment : assignments) {
Mutation m = new Mutation(assignment.tablet.getMetadataEntry());
SuspendingTServer.clearSuspension(m);
assignment.server.putFutureLocation(m);
writer.addMutation(m);
}
} catch (Exception ex) {
throw new DistributedStoreException(ex);
} finally {
try {
writer.close();
} catch (MutationsRejectedException e) {
throw new DistributedStoreException(e);
}
}
}
Aggregations