Search in sources :

Example 1 with AccumuloMergeToolConfiguration

use of org.apache.rya.export.AccumuloMergeToolConfiguration in project incubator-rya by apache.

the class AccumuloConfigurationAdapter method createConfig.

/**
 * @param genConfig - The JAXB generated configuration.
 * @return The {@link MergeConfiguration} used in the application
 * @throws MergeConfigurationException
 */
@Override
public MergeConfiguration createConfig(final MergeToolConfiguration genConfig) throws MergeConfigurationException {
    final AccumuloMergeToolConfiguration aConfig = (AccumuloMergeToolConfiguration) genConfig;
    final DBType parentType = aConfig.getParentDBType();
    final DBType childType = aConfig.getChildDBType();
    final MergeConfiguration.Builder configBuilder = super.getBuilder(aConfig);
    final AccumuloBuilder builder = new AccumuloBuilder(configBuilder);
    if (parentType == DBType.ACCUMULO) {
        verifyParentInstanceType(aConfig);
        builder.setParentZookeepers(aConfig.getParentZookeepers()).setParentAuths(aConfig.getParentAuths()).setParentInstanceType(aConfig.getParentInstanceType());
    }
    if (childType == DBType.ACCUMULO) {
        verifyChildInstanceType(aConfig);
        builder.setChildZookeepers(aConfig.getChildZookeepers()).setChildAuths(aConfig.getChildAuths()).setChildInstanceType(aConfig.getChildInstanceType());
    }
    return builder.build();
}
Also used : AccumuloMergeToolConfiguration(org.apache.rya.export.AccumuloMergeToolConfiguration) AccumuloBuilder(org.apache.rya.export.api.conf.AccumuloMergeConfiguration.AccumuloBuilder) DBType(org.apache.rya.export.DBType)

Example 2 with AccumuloMergeToolConfiguration

use of org.apache.rya.export.AccumuloMergeToolConfiguration in project incubator-rya by apache.

the class AccumuloConfigurationAdapterTest method testCreateConfig.

@Test
public void testCreateConfig() throws MergeConfigurationException {
    final AccumuloMergeToolConfiguration jConfig = mock(AccumuloMergeToolConfiguration.class);
    // Parent Properties
    when(jConfig.getParentHostname()).thenReturn(PARENT_HOST_NAME);
    when(jConfig.getParentPort()).thenReturn(PARENT_PORT);
    when(jConfig.getParentRyaInstanceName()).thenReturn(PARENT_INSTANCE);
    when(jConfig.getParentUsername()).thenReturn(PARENT_USER_NAME);
    when(jConfig.getParentPassword()).thenReturn(PARENT_PASSWORD);
    when(jConfig.getParentTablePrefix()).thenReturn(PARENT_TABLE_PREFIX);
    when(jConfig.getParentDBType()).thenReturn(DBType.ACCUMULO);
    when(jConfig.getParentTomcatUrl()).thenReturn(PARENT_TOMCAT_URL);
    // Parent Accumulo Properties
    when(jConfig.getParentInstanceType()).thenReturn(INSTANCE_TYPE);
    when(jConfig.getParentAuths()).thenReturn(PARENT_AUTH);
    when(jConfig.getParentZookeepers()).thenReturn(PARENT_ZOOKEEPERS);
    // Child Properties
    when(jConfig.getChildHostname()).thenReturn(CHILD_HOST_NAME);
    when(jConfig.getChildPort()).thenReturn(CHILD_PORT);
    when(jConfig.getChildRyaInstanceName()).thenReturn(CHILD_INSTANCE);
    when(jConfig.getChildUsername()).thenReturn(CHILD_USER_NAME);
    when(jConfig.getChildPassword()).thenReturn(CHILD_PASSWORD);
    when(jConfig.getChildTablePrefix()).thenReturn(CHILD_TABLE_PREFIX);
    when(jConfig.getChildDBType()).thenReturn(DBType.MONGO);
    when(jConfig.getChildTomcatUrl()).thenReturn(CHILD_TOMCAT_URL);
    // Other Properties
    when(jConfig.getMergePolicy()).thenReturn(MergePolicy.TIMESTAMP);
    when(jConfig.getNtpServerHost()).thenReturn(TIME_SERVER);
    when(jConfig.isUseNtpServer()).thenReturn(USE_TIME_SYNC);
    final AccumuloConfigurationAdapter adapter = new AccumuloConfigurationAdapter();
    final AccumuloMergeConfiguration accumuloMergeConfiguration = (AccumuloMergeConfiguration) adapter.createConfig(jConfig);
    assertNotNull(accumuloMergeConfiguration);
    assertEquals(AccumuloMergeConfiguration.class, accumuloMergeConfiguration.getClass());
    // Parent Properties
    assertEquals(PARENT_HOST_NAME, accumuloMergeConfiguration.getParentHostname());
    assertEquals(PARENT_USER_NAME, accumuloMergeConfiguration.getParentUsername());
    assertEquals(PARENT_PASSWORD, accumuloMergeConfiguration.getParentPassword());
    assertEquals(PARENT_INSTANCE, accumuloMergeConfiguration.getParentRyaInstanceName());
    assertEquals(PARENT_TABLE_PREFIX, accumuloMergeConfiguration.getParentTablePrefix());
    assertEquals(PARENT_TOMCAT_URL, accumuloMergeConfiguration.getParentTomcatUrl());
    assertEquals(DBType.ACCUMULO, accumuloMergeConfiguration.getParentDBType());
    assertEquals(PARENT_PORT, accumuloMergeConfiguration.getParentPort());
    // Parent Accumulo Properties
    assertEquals(PARENT_ZOOKEEPERS, accumuloMergeConfiguration.getParentZookeepers());
    assertEquals(PARENT_AUTH, accumuloMergeConfiguration.getParentAuths());
    assertEquals(InstanceType.MOCK, accumuloMergeConfiguration.getParentInstanceType());
    // Child Properties
    assertEquals(CHILD_HOST_NAME, accumuloMergeConfiguration.getChildHostname());
    assertEquals(CHILD_USER_NAME, accumuloMergeConfiguration.getChildUsername());
    assertEquals(CHILD_PASSWORD, accumuloMergeConfiguration.getChildPassword());
    assertEquals(CHILD_INSTANCE, accumuloMergeConfiguration.getChildRyaInstanceName());
    assertEquals(CHILD_TABLE_PREFIX, accumuloMergeConfiguration.getChildTablePrefix());
    assertEquals(CHILD_TOMCAT_URL, accumuloMergeConfiguration.getChildTomcatUrl());
    assertEquals(DBType.MONGO, accumuloMergeConfiguration.getChildDBType());
    assertEquals(CHILD_PORT, accumuloMergeConfiguration.getChildPort());
    // Child Properties
    assertNull(accumuloMergeConfiguration.getChildZookeepers());
    assertNull(accumuloMergeConfiguration.getChildAuths());
    assertNull(accumuloMergeConfiguration.getChildInstanceType());
    // Other Properties
    assertEquals(MergePolicy.TIMESTAMP, accumuloMergeConfiguration.getMergePolicy());
    assertTrue(accumuloMergeConfiguration.getUseNtpServer());
    assertEquals(TIME_SERVER, accumuloMergeConfiguration.getNtpServerHost());
}
Also used : AccumuloMergeToolConfiguration(org.apache.rya.export.AccumuloMergeToolConfiguration) Test(org.junit.Test)

Aggregations

AccumuloMergeToolConfiguration (org.apache.rya.export.AccumuloMergeToolConfiguration)2 DBType (org.apache.rya.export.DBType)1 AccumuloBuilder (org.apache.rya.export.api.conf.AccumuloMergeConfiguration.AccumuloBuilder)1 Test (org.junit.Test)1