Search in sources :

Example 6 with AccumuloRyaInstanceDetailsRepository

use of org.apache.rya.accumulo.instance.AccumuloRyaInstanceDetailsRepository in project incubator-rya by apache.

the class AccumuloPcjStorageIT method dropPCJ.

@Test
public void dropPCJ() throws AccumuloException, AccumuloSecurityException, PCJStorageException, NotInitializedException, RyaDetailsRepositoryException {
    // Setup the PCJ storage that will be tested against.
    final Connector connector = super.getClusterInstance().getConnector();
    final String ryaInstanceName = super.getRyaInstanceName();
    try (final PrecomputedJoinStorage pcjStorage = new AccumuloPcjStorage(connector, ryaInstanceName)) {
        // Create a PCJ.
        final String pcjId = pcjStorage.createPcj("SELECT * WHERE { ?a <http://isA> ?b } ");
        // Delete the PCJ that was just created.
        pcjStorage.dropPcj(pcjId);
        // Ensure the Rya details have been updated to no longer include the PCJ's ID.
        final RyaDetailsRepository detailsRepo = new AccumuloRyaInstanceDetailsRepository(connector, ryaInstanceName);
        final ImmutableMap<String, PCJDetails> detailsMap = detailsRepo.getRyaInstanceDetails().getPCJIndexDetails().getPCJDetails();
        assertFalse(detailsMap.containsKey(pcjId));
    }
}
Also used : Connector(org.apache.accumulo.core.client.Connector) AccumuloPcjStorage(org.apache.rya.indexing.pcj.storage.accumulo.AccumuloPcjStorage) PrecomputedJoinStorage(org.apache.rya.indexing.pcj.storage.PrecomputedJoinStorage) RyaDetailsRepository(org.apache.rya.api.instance.RyaDetailsRepository) AccumuloRyaInstanceDetailsRepository(org.apache.rya.accumulo.instance.AccumuloRyaInstanceDetailsRepository) PCJDetails(org.apache.rya.api.instance.RyaDetails.PCJIndexDetails.PCJDetails) Test(org.junit.Test)

Example 7 with AccumuloRyaInstanceDetailsRepository

use of org.apache.rya.accumulo.instance.AccumuloRyaInstanceDetailsRepository in project incubator-rya by apache.

the class RyaSailFactory method updateAccumuloConfig.

public static void updateAccumuloConfig(final AccumuloRdfConfiguration config, final String user, final String pswd, final String ryaInstance) throws AccumuloException, AccumuloSecurityException {
    try {
        final Connector connector = ConfigUtils.getConnector(config);
        final AccumuloRyaInstanceDetailsRepository ryaDetailsRepo = new AccumuloRyaInstanceDetailsRepository(connector, ryaInstance);
        RyaDetailsToConfiguration.addRyaDetailsToConfiguration(ryaDetailsRepo.getRyaInstanceDetails(), config);
    } catch (final RyaDetailsRepositoryException e) {
        LOG.info("Instance does not have a rya details collection, skipping.");
    }
}
Also used : Connector(org.apache.accumulo.core.client.Connector) RyaDetailsRepositoryException(org.apache.rya.api.instance.RyaDetailsRepository.RyaDetailsRepositoryException) AccumuloRyaInstanceDetailsRepository(org.apache.rya.accumulo.instance.AccumuloRyaInstanceDetailsRepository)

Example 8 with AccumuloRyaInstanceDetailsRepository

use of org.apache.rya.accumulo.instance.AccumuloRyaInstanceDetailsRepository in project incubator-rya by apache.

the class DemoDriver method setupRya.

/**
 * Format a Mini Accumulo to be a Rya repository.
 *
 * @param accumulo - The Mini Accumulo cluster Rya will sit on top of. (not null)
 * @return The Rya repository sitting on top of the Mini Accumulo.
 */
private static RyaSailRepository setupRya(final MiniAccumuloCluster accumulo) throws AccumuloException, AccumuloSecurityException, RepositoryException, AlreadyInitializedException, RyaDetailsRepositoryException {
    checkNotNull(accumulo);
    // Setup the Rya Repository that will be used to create Repository Connections.
    final RdfCloudTripleStore ryaStore = new RdfCloudTripleStore();
    final AccumuloRyaDAO crdfdao = new AccumuloRyaDAO();
    crdfdao.setConnector(accumuloConn);
    // Setup Rya configuration values.
    final String ryaInstanceName = "demo_";
    final AccumuloRdfConfiguration conf = new AccumuloRdfConfiguration();
    conf.setTablePrefix("demo_");
    conf.setDisplayQueryPlan(true);
    conf.setBoolean(USE_MOCK_INSTANCE, true);
    conf.set(RdfCloudTripleStoreConfiguration.CONF_TBL_PREFIX, RYA_TABLE_PREFIX);
    conf.set(CLOUDBASE_USER, "root");
    conf.set(CLOUDBASE_PASSWORD, "password");
    conf.set(CLOUDBASE_INSTANCE, accumulo.getInstanceName());
    crdfdao.setConf(conf);
    ryaStore.setRyaDAO(crdfdao);
    final RyaSailRepository ryaRepo = new RyaSailRepository(ryaStore);
    ryaRepo.initialize();
    // Create Rya Details for the instance name.
    final RyaDetailsRepository detailsRepo = new AccumuloRyaInstanceDetailsRepository(accumuloConn, ryaInstanceName);
    final RyaDetails details = RyaDetails.builder().setRyaInstanceName(ryaInstanceName).setRyaVersion("0.0.0.0").setFreeTextDetails(new FreeTextIndexDetails(true)).setEntityCentricIndexDetails(new EntityCentricIndexDetails(true)).setTemporalIndexDetails(new TemporalIndexDetails(true)).setPCJIndexDetails(PCJIndexDetails.builder().setEnabled(true)).setJoinSelectivityDetails(new JoinSelectivityDetails(Optional.<Date>absent())).setProspectorDetails(new ProspectorDetails(Optional.<Date>absent())).build();
    detailsRepo.initialize(details);
    return ryaRepo;
}
Also used : ProspectorDetails(org.apache.rya.api.instance.RyaDetails.ProspectorDetails) RdfCloudTripleStore(org.apache.rya.rdftriplestore.RdfCloudTripleStore) AccumuloRyaDAO(org.apache.rya.accumulo.AccumuloRyaDAO) RyaSailRepository(org.apache.rya.rdftriplestore.RyaSailRepository) RyaDetails(org.apache.rya.api.instance.RyaDetails) AccumuloRdfConfiguration(org.apache.rya.accumulo.AccumuloRdfConfiguration) AccumuloRyaInstanceDetailsRepository(org.apache.rya.accumulo.instance.AccumuloRyaInstanceDetailsRepository) JoinSelectivityDetails(org.apache.rya.api.instance.RyaDetails.JoinSelectivityDetails) Date(java.util.Date) EntityCentricIndexDetails(org.apache.rya.api.instance.RyaDetails.EntityCentricIndexDetails) TemporalIndexDetails(org.apache.rya.api.instance.RyaDetails.TemporalIndexDetails) FreeTextIndexDetails(org.apache.rya.api.instance.RyaDetails.FreeTextIndexDetails) RyaDetailsRepository(org.apache.rya.api.instance.RyaDetailsRepository)

Example 9 with AccumuloRyaInstanceDetailsRepository

use of org.apache.rya.accumulo.instance.AccumuloRyaInstanceDetailsRepository in project incubator-rya by apache.

the class AccumuloInstall method initializeRyaDetails.

/**
 * Initializes the {@link RyaDetails} and stores them for the new instance.
 *
 * @param instanceName - The name of the instance that is being created. (not null)
 * @param installConfig - The instance's install configuration. (not null)
 * @param installUser - The user who is installing the instance of Rya. (not null)
 * @return The {@link RyaDetails} that were stored.
 * @throws AlreadyInitializedException Could not be initialized because
 *   a table with this instance name has already exists and is holding the details.
 * @throws RyaDetailsRepositoryException Something caused the initialization
 *   operation to fail.
 */
private RyaDetails initializeRyaDetails(final String instanceName, final InstallConfiguration installConfig, final String installUser) throws AlreadyInitializedException, RyaDetailsRepositoryException {
    requireNonNull(instanceName);
    requireNonNull(installConfig);
    requireNonNull(installUser);
    final RyaDetailsRepository detailsRepo = new AccumuloRyaInstanceDetailsRepository(getConnector(), instanceName);
    // Build the PCJ Index details.
    final PCJIndexDetails.Builder pcjDetailsBuilder = PCJIndexDetails.builder().setEnabled(installConfig.isPcjIndexEnabled());
    if (installConfig.getFluoPcjAppName().isPresent()) {
        final String fluoPcjAppName = installConfig.getFluoPcjAppName().get();
        pcjDetailsBuilder.setFluoDetails(new FluoDetails(fluoPcjAppName));
    }
    final RyaDetails details = RyaDetails.builder().setRyaInstanceName(instanceName).setRyaVersion(getVersion()).addUser(installUser).setTemporalIndexDetails(new TemporalIndexDetails(installConfig.isTemporalIndexEnabled())).setFreeTextDetails(new FreeTextIndexDetails(installConfig.isFreeTextIndexEnabled())).setEntityCentricIndexDetails(new EntityCentricIndexDetails(installConfig.isEntityCentrixIndexEnabled())).setPCJIndexDetails(pcjDetailsBuilder).setProspectorDetails(new ProspectorDetails(Optional.<Date>absent())).setJoinSelectivityDetails(new JoinSelectivityDetails(Optional.<Date>absent())).build();
    // Initialize the table.
    detailsRepo.initialize(details);
    return details;
}
Also used : ProspectorDetails(org.apache.rya.api.instance.RyaDetails.ProspectorDetails) RyaDetails(org.apache.rya.api.instance.RyaDetails) AccumuloRyaInstanceDetailsRepository(org.apache.rya.accumulo.instance.AccumuloRyaInstanceDetailsRepository) Date(java.util.Date) JoinSelectivityDetails(org.apache.rya.api.instance.RyaDetails.JoinSelectivityDetails) EntityCentricIndexDetails(org.apache.rya.api.instance.RyaDetails.EntityCentricIndexDetails) TemporalIndexDetails(org.apache.rya.api.instance.RyaDetails.TemporalIndexDetails) FreeTextIndexDetails(org.apache.rya.api.instance.RyaDetails.FreeTextIndexDetails) RyaDetailsRepository(org.apache.rya.api.instance.RyaDetailsRepository) FluoDetails(org.apache.rya.api.instance.RyaDetails.PCJIndexDetails.FluoDetails) PCJIndexDetails(org.apache.rya.api.instance.RyaDetails.PCJIndexDetails)

Example 10 with AccumuloRyaInstanceDetailsRepository

use of org.apache.rya.accumulo.instance.AccumuloRyaInstanceDetailsRepository in project incubator-rya by apache.

the class AccumuloRemoveUser method removeUser.

@Override
public void removeUser(final String instanceName, final String username) throws InstanceDoesNotExistException, RyaClientException {
    requireNonNull(instanceName);
    requireNonNull(username);
    // Update the instance details.
    final RyaDetailsUpdater updater = new RyaDetailsUpdater(new AccumuloRyaInstanceDetailsRepository(getConnector(), instanceName));
    try {
        updater.update(originalDetails -> RyaDetails.builder(originalDetails).removeUser(username).build());
    } catch (RyaDetailsRepositoryException | CouldNotApplyMutationException e) {
        throw new RyaClientException("Could not remove the user '" + username + "' from the Rya instance's details.", e);
    }
    // Revoke all access to all the instance's tables.
    try {
        // Build the list of tables that are present within the Rya instance.
        final List<String> tables = new RyaTableNames().getTableNames(instanceName, getConnector());
        // Update the user permissions for those tables.
        for (final String table : tables) {
            try {
                TABLE_PERMISSIONS.revokeAllPermissions(username, table, getConnector());
            } catch (AccumuloException | AccumuloSecurityException e) {
                throw new RyaClientException("Could not revoke access to table '" + table + "' from user '" + username + "'.", e);
            }
        }
    } catch (PCJStorageException | RyaDetailsRepositoryException e) {
        throw new RyaClientException("Could not determine which tables exist for the '" + instanceName + "' instance of Rya.", e);
    }
}
Also used : AccumuloException(org.apache.accumulo.core.client.AccumuloException) RyaClientException(org.apache.rya.api.client.RyaClientException) RyaDetailsUpdater(org.apache.rya.api.instance.RyaDetailsUpdater) CouldNotApplyMutationException(org.apache.rya.api.instance.RyaDetailsUpdater.RyaDetailsMutator.CouldNotApplyMutationException) AccumuloRyaInstanceDetailsRepository(org.apache.rya.accumulo.instance.AccumuloRyaInstanceDetailsRepository) RyaTableNames(org.apache.rya.accumulo.utils.RyaTableNames) RyaDetailsRepositoryException(org.apache.rya.api.instance.RyaDetailsRepository.RyaDetailsRepositoryException) AccumuloSecurityException(org.apache.accumulo.core.client.AccumuloSecurityException) PCJStorageException(org.apache.rya.indexing.pcj.storage.PrecomputedJoinStorage.PCJStorageException)

Aggregations

AccumuloRyaInstanceDetailsRepository (org.apache.rya.accumulo.instance.AccumuloRyaInstanceDetailsRepository)14 RyaDetailsRepository (org.apache.rya.api.instance.RyaDetailsRepository)11 RyaDetails (org.apache.rya.api.instance.RyaDetails)9 RyaDetailsRepositoryException (org.apache.rya.api.instance.RyaDetailsRepository.RyaDetailsRepositoryException)7 RyaClientException (org.apache.rya.api.client.RyaClientException)6 PCJDetails (org.apache.rya.api.instance.RyaDetails.PCJIndexDetails.PCJDetails)5 Date (java.util.Date)4 EntityCentricIndexDetails (org.apache.rya.api.instance.RyaDetails.EntityCentricIndexDetails)4 FreeTextIndexDetails (org.apache.rya.api.instance.RyaDetails.FreeTextIndexDetails)4 JoinSelectivityDetails (org.apache.rya.api.instance.RyaDetails.JoinSelectivityDetails)4 ProspectorDetails (org.apache.rya.api.instance.RyaDetails.ProspectorDetails)4 TemporalIndexDetails (org.apache.rya.api.instance.RyaDetails.TemporalIndexDetails)4 RyaDetailsUpdater (org.apache.rya.api.instance.RyaDetailsUpdater)4 CouldNotApplyMutationException (org.apache.rya.api.instance.RyaDetailsUpdater.RyaDetailsMutator.CouldNotApplyMutationException)4 PrecomputedJoinStorage (org.apache.rya.indexing.pcj.storage.PrecomputedJoinStorage)4 AccumuloPcjStorage (org.apache.rya.indexing.pcj.storage.accumulo.AccumuloPcjStorage)4 Connector (org.apache.accumulo.core.client.Connector)3 InstanceDoesNotExistException (org.apache.rya.api.client.InstanceDoesNotExistException)3 PCJStorageException (org.apache.rya.indexing.pcj.storage.PrecomputedJoinStorage.PCJStorageException)3 AccumuloException (org.apache.accumulo.core.client.AccumuloException)2