use of org.apache.rya.api.instance.RyaDetailsRepository in project incubator-rya by apache.
the class RyaTestInstanceRule method before.
@Override
protected void before() throws Throwable {
// Get the next Rya instance name.
ryaInstanceName = "testInstance_" + ryaInstanceNameCounter.getAndIncrement();
if (install) {
// Create Rya Details for the instance name.
final RyaDetailsRepository detailsRepo = new AccumuloRyaInstanceDetailsRepository(cluster.getConnector(), 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.absent())).setProspectorDetails(new ProspectorDetails(Optional.absent())).build();
detailsRepo.initialize(details);
}
}
use of org.apache.rya.api.instance.RyaDetailsRepository in project incubator-rya by apache.
the class SetRyaStreamsConfigurationBase method setRyaStreamsConfiguration.
@Override
public void setRyaStreamsConfiguration(final String ryaInstance, final RyaStreamsDetails streamsDetails) throws InstanceDoesNotExistException, RyaClientException {
requireNonNull(ryaInstance);
requireNonNull(streamsDetails);
// Verify the Rya Instance exists.
if (!instanceExists.exists(ryaInstance)) {
throw new InstanceDoesNotExistException("There is no Rya instance named '" + ryaInstance + "' in this storage.");
}
// Update the old details object using the provided Rya Streams details.
final RyaDetailsRepository repo = getRyaDetailsRepo(ryaInstance);
try {
new RyaDetailsUpdater(repo).update(oldDetails -> {
final RyaDetails.Builder builder = RyaDetails.builder(oldDetails);
builder.setRyaStreamsDetails(streamsDetails);
return builder.build();
});
} catch (CouldNotApplyMutationException | RyaDetailsRepositoryException e) {
throw new RyaClientException("Unable to update which Rya Streams subsystem is used by the '" + ryaInstance + "' Rya instance.", e);
}
}
use of org.apache.rya.api.instance.RyaDetailsRepository in project incubator-rya by apache.
the class AccumuloGetInstanceDetails method getDetails.
@Override
public Optional<RyaDetails> getDetails(final String instanceName) throws InstanceDoesNotExistException, RyaClientException {
requireNonNull(instanceName);
// Ensure the Rya instance exists.
if (!instanceExists.exists(instanceName)) {
throw new InstanceDoesNotExistException(String.format("There is no Rya instance named '%s'.", instanceName));
}
// If the instance has details, then return them.
final RyaDetailsRepository detailsRepo = new AccumuloRyaInstanceDetailsRepository(getConnector(), instanceName);
try {
return Optional.of(detailsRepo.getRyaInstanceDetails());
} catch (final NotInitializedException e) {
return Optional.absent();
} catch (final RyaDetailsRepositoryException e) {
throw new RyaClientException("Could not fetch the Rya instance's details.", e);
}
}
use of org.apache.rya.api.instance.RyaDetailsRepository in project incubator-rya by apache.
the class AccumuloRyaDetailsRepositoryIT method update.
@Test
public void update() throws AlreadyInitializedException, RyaDetailsRepositoryException, AccumuloException, AccumuloSecurityException {
final String instanceName = getRyaInstanceName();
// Create the metadata object the repository will be initialized with.
final RyaDetails details = RyaDetails.builder().setRyaInstanceName(instanceName).setRyaVersion("1.2.3.4").setEntityCentricIndexDetails(new EntityCentricIndexDetails(true)).setTemporalIndexDetails(new TemporalIndexDetails(true)).setFreeTextDetails(new FreeTextIndexDetails(true)).setPCJIndexDetails(PCJIndexDetails.builder().setEnabled(true).setFluoDetails(new FluoDetails("test_instance_rya_pcj_updater")).addPCJDetails(PCJDetails.builder().setId("pcj 1").setUpdateStrategy(PCJUpdateStrategy.BATCH).setLastUpdateTime(new Date())).addPCJDetails(PCJDetails.builder().setId("pcj 2"))).setProspectorDetails(new ProspectorDetails(Optional.of(new Date()))).setJoinSelectivityDetails(new JoinSelectivityDetails(Optional.of(new Date()))).build();
// Setup the repository that will be tested using a mini instance of Accumulo.
final Connector connector = getClusterInstance().getConnector();
final RyaDetailsRepository repo = new AccumuloRyaInstanceDetailsRepository(connector, instanceName);
// Initialize the repository
repo.initialize(details);
// Create a new state for the details.
final RyaDetails updated = new RyaDetails.Builder(details).setEntityCentricIndexDetails(new EntityCentricIndexDetails(false)).build();
// Execute the update.
repo.update(details, updated);
// Show the new state that is stored matches the updated state.
final RyaDetails fetched = repo.getRyaInstanceDetails();
assertEquals(updated, fetched);
}
use of org.apache.rya.api.instance.RyaDetailsRepository in project incubator-rya by apache.
the class AccumuloRyaDetailsRepositoryIT method initializeAndGet.
@Test
public void initializeAndGet() throws AccumuloException, AccumuloSecurityException, AlreadyInitializedException, RyaDetailsRepositoryException {
final String instanceName = getRyaInstanceName();
// Create the metadata object the repository will be initialized with.
final RyaDetails details = RyaDetails.builder().setRyaInstanceName(instanceName).setRyaVersion("1.2.3.4").setEntityCentricIndexDetails(new EntityCentricIndexDetails(true)).setTemporalIndexDetails(new TemporalIndexDetails(true)).setFreeTextDetails(new FreeTextIndexDetails(true)).setPCJIndexDetails(PCJIndexDetails.builder().setEnabled(true).setFluoDetails(new FluoDetails("test_instance_rya_pcj_updater")).addPCJDetails(PCJDetails.builder().setId("pcj 1").setUpdateStrategy(PCJUpdateStrategy.BATCH).setLastUpdateTime(new Date())).addPCJDetails(PCJDetails.builder().setId("pcj 2"))).setProspectorDetails(new ProspectorDetails(Optional.of(new Date()))).setJoinSelectivityDetails(new JoinSelectivityDetails(Optional.of(new Date()))).build();
// Setup the repository that will be tested using a mini instance of Accumulo.
final Connector connector = getClusterInstance().getConnector();
final RyaDetailsRepository repo = new AccumuloRyaInstanceDetailsRepository(connector, instanceName);
// Initialize the repository
repo.initialize(details);
// Fetch the stored details.
final RyaDetails stored = repo.getRyaInstanceDetails();
// Ensure the fetched object is equivalent to what was stored.
assertEquals(details, stored);
}
Aggregations