Search in sources :

Example 56 with MutationsRejectedException

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);
            }
        }
    }
}
Also used : AccumuloException(org.apache.accumulo.core.client.AccumuloException) TableNotFoundException(org.apache.accumulo.core.client.TableNotFoundException) TableOperations(org.apache.accumulo.core.client.admin.TableOperations) TableExistsException(org.apache.accumulo.core.client.TableExistsException) Value(org.apache.accumulo.core.data.Value) BatchWriterConfig(org.apache.accumulo.core.client.BatchWriterConfig) AccumuloSecurityException(org.apache.accumulo.core.client.AccumuloSecurityException) BatchWriter(org.apache.accumulo.core.client.BatchWriter) Mutation(org.apache.accumulo.core.data.Mutation) ConditionalMutation(org.apache.accumulo.core.data.ConditionalMutation) MutationsRejectedException(org.apache.accumulo.core.client.MutationsRejectedException)

Example 57 with MutationsRejectedException

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);
        }
    }
}
Also used : BatchWriter(org.apache.accumulo.core.client.BatchWriter) Mutation(org.apache.accumulo.core.data.Mutation) MutationsRejectedException(org.apache.accumulo.core.client.MutationsRejectedException) MutationsRejectedException(org.apache.accumulo.core.client.MutationsRejectedException)

Example 58 with MutationsRejectedException

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);
        }
    }
}
Also used : Path(org.apache.hadoop.fs.Path) BatchWriter(org.apache.accumulo.core.client.BatchWriter) Mutation(org.apache.accumulo.core.data.Mutation) LogEntry(org.apache.accumulo.core.tabletserver.log.LogEntry) MutationsRejectedException(org.apache.accumulo.core.client.MutationsRejectedException) MutationsRejectedException(org.apache.accumulo.core.client.MutationsRejectedException)

Example 59 with MutationsRejectedException

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);
        }
    }
}
Also used : BatchWriter(org.apache.accumulo.core.client.BatchWriter) Mutation(org.apache.accumulo.core.data.Mutation) MutationsRejectedException(org.apache.accumulo.core.client.MutationsRejectedException) MutationsRejectedException(org.apache.accumulo.core.client.MutationsRejectedException)

Example 60 with MutationsRejectedException

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);
        }
    }
}
Also used : BatchWriter(org.apache.accumulo.core.client.BatchWriter) Mutation(org.apache.accumulo.core.data.Mutation) MutationsRejectedException(org.apache.accumulo.core.client.MutationsRejectedException) MutationsRejectedException(org.apache.accumulo.core.client.MutationsRejectedException)

Aggregations

MutationsRejectedException (org.apache.accumulo.core.client.MutationsRejectedException)91 Mutation (org.apache.accumulo.core.data.Mutation)62 BatchWriter (org.apache.accumulo.core.client.BatchWriter)52 TableNotFoundException (org.apache.accumulo.core.client.TableNotFoundException)31 Text (org.apache.hadoop.io.Text)31 Value (org.apache.accumulo.core.data.Value)30 BatchWriterConfig (org.apache.accumulo.core.client.BatchWriterConfig)23 Key (org.apache.accumulo.core.data.Key)21 IOException (java.io.IOException)20 HashMap (java.util.HashMap)15 AccumuloSecurityException (org.apache.accumulo.core.client.AccumuloSecurityException)13 AccumuloException (org.apache.accumulo.core.client.AccumuloException)12 ConstraintViolationSummary (org.apache.accumulo.core.data.ConstraintViolationSummary)10 ColumnVisibility (org.apache.accumulo.core.security.ColumnVisibility)10 ArrayList (java.util.ArrayList)9 Scanner (org.apache.accumulo.core.client.Scanner)9 Set (java.util.Set)8 Test (org.junit.Test)8 List (java.util.List)7 Entry (java.util.Map.Entry)7