Search in sources :

Example 76 with RyaClient

use of org.apache.rya.api.client.RyaClient in project incubator-rya by apache.

the class RyaAdminCommandsTest method createPCJ_cancelledPrompt.

@Test
public void createPCJ_cancelledPrompt() throws InstanceDoesNotExistException, RyaClientException, IOException {
    // Mock the object that performs the create operation.
    final String instanceName = "unitTest";
    final RyaClient mockCommands = mock(RyaClient.class);
    final SharedShellState state = new SharedShellState();
    state.connectedToAccumulo(mock(AccumuloConnectionDetails.class), mockCommands);
    state.connectedToInstance(instanceName);
    final SparqlPrompt mockSparqlPrompt = mock(SparqlPrompt.class);
    when(mockSparqlPrompt.getSparql()).thenReturn(Optional.absent());
    // Execute the command.
    final RyaAdminCommands commands = new RyaAdminCommands(state, mock(InstallPrompt.class), mockSparqlPrompt, mock(UninstallPrompt.class));
    final String message = commands.createPcj(true, false);
    // Verify a message is returned that explains what was created.
    final String expected = "";
    assertEquals(expected, message);
}
Also used : AccumuloConnectionDetails(org.apache.rya.api.client.accumulo.AccumuloConnectionDetails) SparqlPrompt(org.apache.rya.shell.util.SparqlPrompt) RyaClient(org.apache.rya.api.client.RyaClient) InstallPrompt(org.apache.rya.shell.util.InstallPrompt) UninstallPrompt(org.apache.rya.shell.util.UninstallPrompt) Test(org.junit.Test)

Example 77 with RyaClient

use of org.apache.rya.api.client.RyaClient in project incubator-rya by apache.

the class SharedShellStateTest method connectedToInstance.

@Test
public void connectedToInstance() {
    final SharedShellState state = new SharedShellState();
    // Connect to Accumulo.
    final AccumuloConnectionDetails connectionDetails = mock(AccumuloConnectionDetails.class);
    final RyaClient connectedCommands = mock(RyaClient.class);
    state.connectedToAccumulo(connectionDetails, connectedCommands);
    // Connect to an Instance.
    state.connectedToInstance("instance");
    // Verify the state.
    final ShellState expected = ShellState.builder().setConnectionState(ConnectionState.CONNECTED_TO_INSTANCE).setAccumuloDetails(connectionDetails).setConnectedCommands(connectedCommands).setRyaInstanceName("instance").build();
    assertEquals(expected, state.getShellState());
}
Also used : AccumuloConnectionDetails(org.apache.rya.api.client.accumulo.AccumuloConnectionDetails) ShellState(org.apache.rya.shell.SharedShellState.ShellState) RyaClient(org.apache.rya.api.client.RyaClient) Test(org.junit.Test)

Example 78 with RyaClient

use of org.apache.rya.api.client.RyaClient in project incubator-rya by apache.

the class SharedShellStateTest method disconnected.

@Test
public void disconnected() {
    final SharedShellState state = new SharedShellState();
    // Connect to Accumulo and an instance.
    final AccumuloConnectionDetails connectionDetails = mock(AccumuloConnectionDetails.class);
    final RyaClient connectedCommands = mock(RyaClient.class);
    state.connectedToAccumulo(connectionDetails, connectedCommands);
    state.connectedToInstance("instance");
    // Disconnect.
    state.disconnected();
    // Verify the state.
    final ShellState expected = ShellState.builder().setConnectionState(ConnectionState.DISCONNECTED).build();
    assertEquals(expected, state.getShellState());
}
Also used : AccumuloConnectionDetails(org.apache.rya.api.client.accumulo.AccumuloConnectionDetails) ShellState(org.apache.rya.shell.SharedShellState.ShellState) RyaClient(org.apache.rya.api.client.RyaClient) Test(org.junit.Test)

Example 79 with RyaClient

use of org.apache.rya.api.client.RyaClient in project incubator-rya by apache.

the class SharedShellStateTest method disconnectedToConnectedToStorage.

@Test
public void disconnectedToConnectedToStorage() {
    final SharedShellState state = new SharedShellState();
    // Connect to Accumulo.
    final AccumuloConnectionDetails connectionDetails = mock(AccumuloConnectionDetails.class);
    final RyaClient connectedCommands = mock(RyaClient.class);
    state.connectedToAccumulo(connectionDetails, connectedCommands);
    // Verify the state.
    final ShellState expected = ShellState.builder().setConnectionState(ConnectionState.CONNECTED_TO_STORAGE).setAccumuloDetails(connectionDetails).setConnectedCommands(connectedCommands).build();
    assertEquals(expected, state.getShellState());
}
Also used : AccumuloConnectionDetails(org.apache.rya.api.client.accumulo.AccumuloConnectionDetails) ShellState(org.apache.rya.shell.SharedShellState.ShellState) RyaClient(org.apache.rya.api.client.RyaClient) Test(org.junit.Test)

Example 80 with RyaClient

use of org.apache.rya.api.client.RyaClient in project incubator-rya by apache.

the class QueryBenchmarkRunIT method setup.

@BeforeClass
public static void setup() throws Exception {
    // Squash loud logs.
    Logger.getLogger(ClientCnxn.class).setLevel(Level.ERROR);
    // Setup the Mini Accumulo Cluster.
    final File miniDataDir = com.google.common.io.Files.createTempDir();
    final MiniAccumuloConfig cfg = new MiniAccumuloConfig(miniDataDir, ACCUMULO_PASSWORD);
    cluster = new MiniAccumuloCluster(cfg);
    cluster.start();
    // Create a Rya Client connected to the Mini Accumulo Cluster.
    final AccumuloConnectionDetails connDetails = new AccumuloConnectionDetails(ACCUMULO_USER, ACCUMULO_PASSWORD.toCharArray(), cluster.getInstanceName(), cluster.getZooKeepers());
    final Connector connector = cluster.getConnector(ACCUMULO_USER, ACCUMULO_PASSWORD);
    final RyaClient ryaClient = AccumuloRyaClientFactory.build(connDetails, connector);
    // Install an instance of Rya on the mini cluster.
    installRya(ryaClient);
    // Get a Sail object that is backed by the Rya store that is on the mini cluster.
    final AccumuloRdfConfiguration ryaConf = new AccumuloRdfConfiguration();
    ryaConf.setTablePrefix(RYA_INSTANCE_NAME);
    ryaConf.set(ConfigUtils.CLOUDBASE_USER, ACCUMULO_USER);
    ryaConf.set(ConfigUtils.CLOUDBASE_PASSWORD, ACCUMULO_PASSWORD);
    ryaConf.set(ConfigUtils.CLOUDBASE_ZOOKEEPERS, cluster.getZooKeepers());
    ryaConf.set(ConfigUtils.CLOUDBASE_INSTANCE, cluster.getInstanceName());
    ryaConf.set(ConfigUtils.USE_PCJ, "true");
    ryaConf.set(ConfigUtils.PCJ_STORAGE_TYPE, PrecomputedJoinStorageType.ACCUMULO.toString());
    ryaConf.set(ConfigUtils.PCJ_UPDATER_TYPE, PrecomputedJoinUpdaterType.NO_UPDATE.toString());
    sail = RyaSailFactory.getInstance(ryaConf);
    // Load some data into the cluster that will match the query we're testing against.
    loadTestStatements();
    // Add a PCJ to the application that summarizes the query.
    createTestPCJ(ryaClient);
}
Also used : Connector(org.apache.accumulo.core.client.Connector) AccumuloConnectionDetails(org.apache.rya.api.client.accumulo.AccumuloConnectionDetails) MiniAccumuloCluster(org.apache.accumulo.minicluster.MiniAccumuloCluster) MiniAccumuloConfig(org.apache.accumulo.minicluster.MiniAccumuloConfig) RyaClient(org.apache.rya.api.client.RyaClient) ClientCnxn(org.apache.zookeeper.ClientCnxn) File(java.io.File) AccumuloRdfConfiguration(org.apache.rya.accumulo.AccumuloRdfConfiguration) BeforeClass(org.junit.BeforeClass)

Aggregations

RyaClient (org.apache.rya.api.client.RyaClient)105 Test (org.junit.Test)76 AccumuloConnectionDetails (org.apache.rya.api.client.accumulo.AccumuloConnectionDetails)41 SparqlPrompt (org.apache.rya.shell.util.SparqlPrompt)29 InstallConfiguration (org.apache.rya.api.client.Install.InstallConfiguration)26 CliCommand (org.springframework.shell.core.annotation.CliCommand)20 RyaClientException (org.apache.rya.api.client.RyaClientException)18 Install (org.apache.rya.api.client.Install)17 ShellState (org.apache.rya.shell.SharedShellState.ShellState)16 InstallPrompt (org.apache.rya.shell.util.InstallPrompt)16 UninstallPrompt (org.apache.rya.shell.util.UninstallPrompt)16 RyaDetails (org.apache.rya.api.instance.RyaDetails)14 ConsolePrinter (org.apache.rya.shell.util.ConsolePrinter)13 IOException (java.io.IOException)11 InstanceDoesNotExistException (org.apache.rya.api.client.InstanceDoesNotExistException)9 Sail (org.openrdf.sail.Sail)9 ValueFactory (org.openrdf.model.ValueFactory)8 HashSet (java.util.HashSet)7 Connector (org.apache.accumulo.core.client.Connector)7 AccumuloRdfConfiguration (org.apache.rya.accumulo.AccumuloRdfConfiguration)7