Search in sources :

Example 1 with PersistedOptionValue

use of org.apache.drill.exec.server.options.PersistedOptionValue in project drill by axbaretto.

the class TestPStoreProviders method zkBackwardCompatabilityTest.

/**
 * DRILL-5809
 * Note: If this test breaks you are probably breaking backward and forward compatibility. Verify with the community
 * that breaking compatibility is acceptable and planned for.
 * @throws Exception
 */
@Test
public void zkBackwardCompatabilityTest() throws Exception {
    final String oldName = "myOldOption";
    try (CuratorFramework curator = createCurator()) {
        curator.start();
        PersistentStoreConfig<PersistedOptionValue> storeConfig = PersistentStoreConfig.newJacksonBuilder(new ObjectMapper(), PersistedOptionValue.class).name("sys.test").build();
        try (ZookeeperClient zkClient = new ZookeeperClient(curator, PathUtils.join("/", storeConfig.getName()), CreateMode.PERSISTENT)) {
            zkClient.start();
            String oldOptionJson = DrillFileUtils.getResourceAsString("/options/old_booleanopt.json");
            zkClient.put(oldName, oldOptionJson.getBytes(), null);
        }
        try (ZookeeperPersistentStoreProvider provider = new ZookeeperPersistentStoreProvider(zkHelper.getConfig(), curator)) {
            PersistentStore<PersistedOptionValue> store = provider.getOrCreateStore(storeConfig);
            assertTrue(store instanceof ZookeeperPersistentStore);
            PersistedOptionValue oldOptionValue = ((ZookeeperPersistentStore<PersistedOptionValue>) store).get(oldName, null);
            PersistedOptionValue expectedValue = new PersistedOptionValue("true");
            Assert.assertEquals(expectedValue, oldOptionValue);
        }
    }
}
Also used : ZookeeperClient(org.apache.drill.exec.coord.zk.ZookeeperClient) CuratorFramework(org.apache.curator.framework.CuratorFramework) ZookeeperPersistentStore(org.apache.drill.exec.store.sys.store.ZookeeperPersistentStore) PersistedOptionValue(org.apache.drill.exec.server.options.PersistedOptionValue) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) ZookeeperPersistentStoreProvider(org.apache.drill.exec.store.sys.store.provider.ZookeeperPersistentStoreProvider) SlowTest(org.apache.drill.categories.SlowTest) Test(org.junit.Test)

Example 2 with PersistedOptionValue

use of org.apache.drill.exec.server.options.PersistedOptionValue in project drill by apache.

the class TestPStoreProviders method zkBackwardCompatabilityTest.

/**
 * DRILL-5809
 * Note: If this test breaks you are probably breaking backward and forward compatibility. Verify with the community
 * that breaking compatibility is acceptable and planned for.
 * @throws Exception
 */
@Test
public void zkBackwardCompatabilityTest() throws Exception {
    final String oldName = "myOldOption";
    try (CuratorFramework curator = createCurator()) {
        curator.start();
        PersistentStoreConfig<PersistedOptionValue> storeConfig = PersistentStoreConfig.newJacksonBuilder(new ObjectMapper(), PersistedOptionValue.class).name("sys.test").build();
        try (ZookeeperClient zkClient = new ZookeeperClient(curator, PathUtils.join("/", storeConfig.getName()), CreateMode.PERSISTENT)) {
            zkClient.start();
            String oldOptionJson = DrillFileUtils.getResourceAsString("/options/old_booleanopt.json");
            zkClient.put(oldName, oldOptionJson.getBytes(), null);
        }
        try (ZookeeperPersistentStoreProvider provider = new ZookeeperPersistentStoreProvider(zkHelper.getConfig(), curator)) {
            PersistentStore<PersistedOptionValue> store = provider.getOrCreateStore(storeConfig);
            assertTrue(store instanceof ZookeeperPersistentStore);
            PersistedOptionValue oldOptionValue = ((ZookeeperPersistentStore<PersistedOptionValue>) store).get(oldName, null);
            PersistedOptionValue expectedValue = new PersistedOptionValue("true");
            Assert.assertEquals(expectedValue, oldOptionValue);
        }
    }
}
Also used : ZookeeperClient(org.apache.drill.exec.coord.zk.ZookeeperClient) CuratorFramework(org.apache.curator.framework.CuratorFramework) ZookeeperPersistentStore(org.apache.drill.exec.store.sys.store.ZookeeperPersistentStore) PersistedOptionValue(org.apache.drill.exec.server.options.PersistedOptionValue) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) ZookeeperPersistentStoreProvider(org.apache.drill.exec.store.sys.store.provider.ZookeeperPersistentStoreProvider) SlowTest(org.apache.drill.categories.SlowTest) Test(org.junit.Test) FlakyTest(org.apache.drill.categories.FlakyTest)

Aggregations

ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 CuratorFramework (org.apache.curator.framework.CuratorFramework)2 SlowTest (org.apache.drill.categories.SlowTest)2 ZookeeperClient (org.apache.drill.exec.coord.zk.ZookeeperClient)2 PersistedOptionValue (org.apache.drill.exec.server.options.PersistedOptionValue)2 ZookeeperPersistentStore (org.apache.drill.exec.store.sys.store.ZookeeperPersistentStore)2 ZookeeperPersistentStoreProvider (org.apache.drill.exec.store.sys.store.provider.ZookeeperPersistentStoreProvider)2 Test (org.junit.Test)2 FlakyTest (org.apache.drill.categories.FlakyTest)1