use of org.apache.accumulo.core.client.MutationsRejectedException in project incubator-rya by apache.
the class PcjTables method purgePcjTable.
/**
* Deletes all of the rows that are in a PCJ index and sets its cardinality back to 0.
*
* @param accumuloConn - Connects to the Accumulo that hosts the PCJ indices. (not null)
* @param pcjTableName - The name of the PCJ table that will be purged. (not null)
* @throws PCJStorageException Either the rows could not be dropped from the
* PCJ table or the metadata could not be written back to the table.
*/
public void purgePcjTable(final Connector accumuloConn, final String pcjTableName) throws PCJStorageException {
checkNotNull(accumuloConn);
checkNotNull(pcjTableName);
// Fetch the metadaata from the PCJ table.
final PcjMetadata oldMetadata = getPcjMetadata(accumuloConn, pcjTableName);
// Delete all of the rows
try {
accumuloConn.tableOperations().deleteRows(pcjTableName, null, null);
} catch (AccumuloException | AccumuloSecurityException | TableNotFoundException e) {
throw new PCJStorageException("Could not delete the rows of data from PCJ table named: " + pcjTableName, e);
}
// Store the new metadata.
final PcjMetadata newMetadata = new PcjMetadata(oldMetadata.getSparql(), 0L, oldMetadata.getVarOrders());
final List<Mutation> mutations = makeWriteMetadataMutations(newMetadata);
BatchWriter writer = null;
try {
writer = accumuloConn.createBatchWriter(pcjTableName, new BatchWriterConfig());
writer.addMutations(mutations);
writer.flush();
} catch (final TableNotFoundException | MutationsRejectedException e) {
throw new PCJStorageException("Could not rewrite the PCJ cardinality for table named '" + pcjTableName + "'. This table will not work anymore.", e);
} finally {
if (writer != null) {
try {
writer.close();
} catch (final MutationsRejectedException e) {
throw new PCJStorageException("Could not close the batch writer.", e);
}
}
}
}
use of org.apache.accumulo.core.client.MutationsRejectedException in project incubator-rya by apache.
the class AccumuloRyaDAO method flush.
@Override
public void flush() throws RyaDAOException {
try {
mt_bw.flush();
flushIndexers();
} catch (final MutationsRejectedException e) {
throw new RyaDAOException(e);
}
}
use of org.apache.accumulo.core.client.MutationsRejectedException in project incubator-rya by apache.
the class AccumuloRyaDAO method purge.
@Override
public void purge(final RdfCloudTripleStoreConfiguration configuration) {
for (final String tableName : getTables()) {
try {
purge(tableName, configuration.getAuths());
compact(tableName);
} catch (final TableNotFoundException e) {
logger.error(e.getMessage());
} catch (final MutationsRejectedException e) {
logger.error(e.getMessage());
}
}
for (final AccumuloIndexer indexer : this.secondaryIndexers) {
try {
indexer.purge(configuration);
} catch (final Exception e) {
logger.error("Failed to purge indexer", e);
}
}
}
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);
}
}
}
Aggregations