Search in sources :

Example 41 with RyaDetails

use of org.apache.rya.api.instance.RyaDetails in project incubator-rya by apache.

the class AccumuloAddUserIT method userAddedAlsoAddedToRyaDetails.

/**
 * Ensure that when a user is added to a Rya instance that its details are updated to include the new user.
 */
@Test
public void userAddedAlsoAddedToRyaDetails() throws Exception {
    final String user = testInstance.createUniqueUser();
    final SecurityOperations secOps = super.getConnector().securityOperations();
    final RyaClient userAClient = AccumuloRyaClientFactory.build(new AccumuloConnectionDetails(ADMIN_USER, ADMIN_USER.toCharArray(), getInstanceName(), getZookeepers()), super.getClusterInstance().getCluster().getConnector(ADMIN_USER, ADMIN_USER));
    // Create the user that will be added to the instance of Rya.
    secOps.createLocalUser(user, new PasswordToken(user));
    // Install the instance of Rya.
    userAClient.getInstall().install(getRyaInstanceName(), InstallConfiguration.builder().build());
    // Add the user.
    userAClient.getAddUser().get().addUser(getRyaInstanceName(), user);
    // Ensure the Rya instance's details have been updated to include the added user.
    final ImmutableList<String> expectedUsers = ImmutableList.<String>builder().add(ADMIN_USER).add(user).build();
    final RyaDetails details = userAClient.getGetInstanceDetails().getDetails(getRyaInstanceName()).get();
    assertEquals(expectedUsers, details.getUsers());
}
Also used : PasswordToken(org.apache.accumulo.core.client.security.tokens.PasswordToken) SecurityOperations(org.apache.accumulo.core.client.admin.SecurityOperations) RyaDetails(org.apache.rya.api.instance.RyaDetails) RyaClient(org.apache.rya.api.client.RyaClient) Test(org.junit.Test)

Example 42 with RyaDetails

use of org.apache.rya.api.instance.RyaDetails in project incubator-rya by apache.

the class AccumuloCreatePCJIT method createPCJ.

@Test
public void createPCJ() throws Exception {
    AccumuloConnectionDetails connectionDetails = createConnectionDetails();
    // Initialize the commands that will be used by this test.
    final CreatePCJ createPCJ = new AccumuloCreatePCJ(connectionDetails, accumuloConn);
    // Create a PCJ.
    final String sparql = "SELECT ?x " + "WHERE { " + "?x <http://talksTo> <http://Eve>. " + "?x <http://worksAt> <http://TacoJoint>." + "}";
    final String pcjId = createPCJ.createPCJ(getRyaInstanceName(), sparql);
    // Verify the RyaDetails were updated to include the new PCJ.
    final Optional<RyaDetails> ryaDetails = new AccumuloGetInstanceDetails(connectionDetails, accumuloConn).getDetails(getRyaInstanceName());
    final PCJDetails pcjDetails = ryaDetails.get().getPCJIndexDetails().getPCJDetails().get(pcjId);
    assertEquals(pcjId, pcjDetails.getId());
    assertFalse(pcjDetails.getLastUpdateTime().isPresent());
    assertEquals(PCJUpdateStrategy.INCREMENTAL, pcjDetails.getUpdateStrategy().get());
    try (final PrecomputedJoinStorage pcjStorage = new AccumuloPcjStorage(accumuloConn, getRyaInstanceName())) {
        final PcjMetadata pcjMetadata = pcjStorage.getPcjMetadata(pcjId);
        assertEquals(sparql, pcjMetadata.getSparql());
        assertEquals(0L, pcjMetadata.getCardinality());
        // Verify a Query ID was added for the query within the Fluo app.
        final List<String> fluoQueryIds = new ListQueryIds().listQueryIds(fluoClient);
        assertEquals(1, fluoQueryIds.size());
        // Insert some statements into Rya.
        final ValueFactory vf = ryaRepo.getValueFactory();
        ryaConn.add(vf.createURI("http://Alice"), vf.createURI("http://talksTo"), vf.createURI("http://Eve"));
        ryaConn.add(vf.createURI("http://Bob"), vf.createURI("http://talksTo"), vf.createURI("http://Eve"));
        ryaConn.add(vf.createURI("http://Charlie"), vf.createURI("http://talksTo"), vf.createURI("http://Eve"));
        ryaConn.add(vf.createURI("http://Eve"), vf.createURI("http://helps"), vf.createURI("http://Kevin"));
        ryaConn.add(vf.createURI("http://Bob"), vf.createURI("http://worksAt"), vf.createURI("http://TacoJoint"));
        ryaConn.add(vf.createURI("http://Charlie"), vf.createURI("http://worksAt"), vf.createURI("http://TacoJoint"));
        ryaConn.add(vf.createURI("http://Eve"), vf.createURI("http://worksAt"), vf.createURI("http://TacoJoint"));
        ryaConn.add(vf.createURI("http://David"), vf.createURI("http://worksAt"), vf.createURI("http://TacoJoint"));
        // Verify the correct results were exported.
        fluo.waitForObservers();
        final Set<BindingSet> results = Sets.newHashSet(pcjStorage.listResults(pcjId));
        final MapBindingSet bob = new MapBindingSet();
        bob.addBinding("x", vf.createURI("http://Bob"));
        final MapBindingSet charlie = new MapBindingSet();
        charlie.addBinding("x", vf.createURI("http://Charlie"));
        final Set<BindingSet> expected = Sets.<BindingSet>newHashSet(bob, charlie);
        assertEquals(expected, results);
    }
}
Also used : MapBindingSet(org.openrdf.query.impl.MapBindingSet) BindingSet(org.openrdf.query.BindingSet) AccumuloPcjStorage(org.apache.rya.indexing.pcj.storage.accumulo.AccumuloPcjStorage) CreatePCJ(org.apache.rya.api.client.CreatePCJ) RyaDetails(org.apache.rya.api.instance.RyaDetails) ValueFactory(org.openrdf.model.ValueFactory) PCJDetails(org.apache.rya.api.instance.RyaDetails.PCJIndexDetails.PCJDetails) ListQueryIds(org.apache.rya.indexing.pcj.fluo.api.ListQueryIds) PrecomputedJoinStorage(org.apache.rya.indexing.pcj.storage.PrecomputedJoinStorage) PcjMetadata(org.apache.rya.indexing.pcj.storage.PcjMetadata) MapBindingSet(org.openrdf.query.impl.MapBindingSet) Test(org.junit.Test)

Example 43 with RyaDetails

use of org.apache.rya.api.instance.RyaDetails in project incubator-rya by apache.

the class AccumuloGetInstanceDetailsIT method getDetails.

@Test
public void getDetails() throws AccumuloException, AccumuloSecurityException, DuplicateInstanceNameException, RyaClientException {
    // Install an instance of Rya.
    final String instanceName = getRyaInstanceName();
    final InstallConfiguration installConfig = InstallConfiguration.builder().setEnableTableHashPrefix(true).setEnableEntityCentricIndex(true).setEnableFreeTextIndex(true).setEnableTemporalIndex(true).setEnablePcjIndex(true).setEnableGeoIndex(true).build();
    final AccumuloConnectionDetails connectionDetails = new AccumuloConnectionDetails(getUsername(), getPassword().toCharArray(), getInstanceName(), getZookeepers());
    final Install install = new AccumuloInstall(connectionDetails, getConnector());
    install.install(instanceName, installConfig);
    // Verify the correct details were persisted.
    final GetInstanceDetails getInstanceDetails = new AccumuloGetInstanceDetails(connectionDetails, getConnector());
    final Optional<RyaDetails> details = getInstanceDetails.getDetails(instanceName);
    final RyaDetails expectedDetails = RyaDetails.builder().setRyaInstanceName(instanceName).setRyaVersion(details.get().getRyaVersion()).setTemporalIndexDetails(new TemporalIndexDetails(true)).setFreeTextDetails(new FreeTextIndexDetails(true)).setEntityCentricIndexDetails(new EntityCentricIndexDetails(true)).setPCJIndexDetails(PCJIndexDetails.builder().setEnabled(true)).setProspectorDetails(new ProspectorDetails(Optional.<Date>absent())).setJoinSelectivityDetails(new JoinSelectivityDetails(Optional.<Date>absent())).build();
    assertEquals(expectedDetails, details.get());
}
Also used : ProspectorDetails(org.apache.rya.api.instance.RyaDetails.ProspectorDetails) RyaDetails(org.apache.rya.api.instance.RyaDetails) InstallConfiguration(org.apache.rya.api.client.Install.InstallConfiguration) 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) GetInstanceDetails(org.apache.rya.api.client.GetInstanceDetails) FreeTextIndexDetails(org.apache.rya.api.instance.RyaDetails.FreeTextIndexDetails) Install(org.apache.rya.api.client.Install) Test(org.junit.Test)

Example 44 with RyaDetails

use of org.apache.rya.api.instance.RyaDetails in project incubator-rya by apache.

the class MongoPcjStorage method listPcjs.

@Override
public List<String> listPcjs() throws PCJStorageException {
    try {
        final RyaDetails details = ryaDetailsRepo.getRyaInstanceDetails();
        final PCJIndexDetails pcjIndexDetails = details.getPCJIndexDetails();
        final List<String> pcjIds = new ArrayList<>(pcjIndexDetails.getPCJDetails().keySet());
        return pcjIds;
    } catch (final RyaDetailsRepositoryException e) {
        throw new PCJStorageException("Could not check to see if RyaDetails exist for the instance.", e);
    }
}
Also used : ArrayList(java.util.ArrayList) RyaDetails(org.apache.rya.api.instance.RyaDetails) RyaDetailsRepositoryException(org.apache.rya.api.instance.RyaDetailsRepository.RyaDetailsRepositoryException) PCJIndexDetails(org.apache.rya.api.instance.RyaDetails.PCJIndexDetails)

Example 45 with RyaDetails

use of org.apache.rya.api.instance.RyaDetails in project incubator-rya by apache.

the class MongoCreatePCJIT method createPCJ.

@Test
public void createPCJ() throws Exception {
    final MongoConnectionDetails connectionDetails = getConnectionDetails();
    final RyaClient ryaClient = MongoRyaClientFactory.build(connectionDetails, getMongoClient());
    // Initialize the commands that will be used by this test.
    final CreatePCJ createPCJ = ryaClient.getCreatePCJ();
    final Install installRya = ryaClient.getInstall();
    final InstallConfiguration installConf = InstallConfiguration.builder().setEnablePcjIndex(true).build();
    installRya.install(conf.getRyaInstanceName(), installConf);
    System.out.println(getMongoClient().getDatabase(conf.getRyaInstanceName()).getCollection("instance_details").find().first().toJson());
    // Create a PCJ.
    final String sparql = "SELECT ?x " + "WHERE { " + "?x <http://talksTo> <http://Eve>. " + "?x <http://worksAt> <http://TacoJoint>." + "}";
    final String pcjId = createPCJ.createPCJ(conf.getRyaInstanceName(), sparql);
    // Verify the RyaDetails were updated to include the new PCJ.
    final Optional<RyaDetails> ryaDetails = ryaClient.getGetInstanceDetails().getDetails(conf.getRyaInstanceName());
    final ImmutableMap<String, PCJDetails> details = ryaDetails.get().getPCJIndexDetails().getPCJDetails();
    final PCJDetails pcjDetails = details.get(pcjId);
    assertEquals(pcjId, pcjDetails.getId());
    assertFalse(pcjDetails.getLastUpdateTime().isPresent());
    try (final PrecomputedJoinStorage pcjStorage = new MongoPcjStorage(getMongoClient(), conf.getRyaInstanceName())) {
        final PcjMetadata pcjMetadata = pcjStorage.getPcjMetadata(pcjId);
        // confirm that the pcj was added to the pcj store.
        assertEquals(sparql, pcjMetadata.getSparql());
        assertEquals(0L, pcjMetadata.getCardinality());
    }
}
Also used : CreatePCJ(org.apache.rya.api.client.CreatePCJ) AccumuloCreatePCJ(org.apache.rya.api.client.accumulo.AccumuloCreatePCJ) RyaDetails(org.apache.rya.api.instance.RyaDetails) RyaClient(org.apache.rya.api.client.RyaClient) InstallConfiguration(org.apache.rya.api.client.Install.InstallConfiguration) PCJDetails(org.apache.rya.api.instance.RyaDetails.PCJIndexDetails.PCJDetails) MongoPcjStorage(org.apache.rya.indexing.pcj.storage.mongo.MongoPcjStorage) PrecomputedJoinStorage(org.apache.rya.indexing.pcj.storage.PrecomputedJoinStorage) PcjMetadata(org.apache.rya.indexing.pcj.storage.PcjMetadata) Install(org.apache.rya.api.client.Install) Test(org.junit.Test)

Aggregations

RyaDetails (org.apache.rya.api.instance.RyaDetails)57 Test (org.junit.Test)30 Date (java.util.Date)25 EntityCentricIndexDetails (org.apache.rya.api.instance.RyaDetails.EntityCentricIndexDetails)25 FreeTextIndexDetails (org.apache.rya.api.instance.RyaDetails.FreeTextIndexDetails)25 JoinSelectivityDetails (org.apache.rya.api.instance.RyaDetails.JoinSelectivityDetails)25 ProspectorDetails (org.apache.rya.api.instance.RyaDetails.ProspectorDetails)25 TemporalIndexDetails (org.apache.rya.api.instance.RyaDetails.TemporalIndexDetails)25 RyaDetailsRepository (org.apache.rya.api.instance.RyaDetailsRepository)21 FluoDetails (org.apache.rya.api.instance.RyaDetails.PCJIndexDetails.FluoDetails)18 RyaClientException (org.apache.rya.api.client.RyaClientException)17 RyaClient (org.apache.rya.api.client.RyaClient)14 RyaDetailsRepositoryException (org.apache.rya.api.instance.RyaDetailsRepository.RyaDetailsRepositoryException)10 AccumuloRyaInstanceDetailsRepository (org.apache.rya.accumulo.instance.AccumuloRyaInstanceDetailsRepository)9 GetInstanceDetails (org.apache.rya.api.client.GetInstanceDetails)9 PCJIndexDetails (org.apache.rya.api.instance.RyaDetails.PCJIndexDetails)9 InstanceDoesNotExistException (org.apache.rya.api.client.InstanceDoesNotExistException)8 PCJDetails (org.apache.rya.api.instance.RyaDetails.PCJIndexDetails.PCJDetails)8 RyaStreamsDetails (org.apache.rya.api.instance.RyaDetails.RyaStreamsDetails)6 BasicDBObject (com.mongodb.BasicDBObject)5