use of org.apache.drill.exec.store.sys.store.DataChangeVersion in project drill by axbaretto.
the class TestZookeeperClient method testHasPathTrueWithVersion.
@Test
public void testHasPathTrueWithVersion() {
client.put(path, data);
DataChangeVersion version0 = new DataChangeVersion();
assertTrue(client.hasPath(path, true, version0));
assertEquals("Versions should match", 0, version0.getVersion());
client.put(path, data);
DataChangeVersion version1 = new DataChangeVersion();
assertTrue(client.hasPath(path, true, version1));
assertEquals("Versions should match", 1, version1.getVersion());
}
use of org.apache.drill.exec.store.sys.store.DataChangeVersion in project drill by axbaretto.
the class TestZookeeperClient method testGetWithVersion.
@Test
public void testGetWithVersion() {
client.put(path, data);
DataChangeVersion version0 = new DataChangeVersion();
client.get(path, version0);
assertEquals("Versions should match", 0, version0.getVersion());
client.put(path, data);
DataChangeVersion version1 = new DataChangeVersion();
client.get(path, version1);
assertEquals("Versions should match", 1, version1.getVersion());
}
use of org.apache.drill.exec.store.sys.store.DataChangeVersion in project drill by axbaretto.
the class TestDynamicUDFSupport method testDropFunction.
@Test
public void testDropFunction() throws Exception {
copyDefaultJarsToStagingArea();
test("create function using jar '%s'", default_binary_name);
test("select custom_lower('A') from (values(1))");
Path localUdfDirPath = hadoopToJavaPath((org.apache.hadoop.fs.Path) FieldUtils.readField(getDrillbitContext().getFunctionImplementationRegistry(), "localUdfDir", true));
assertTrue("Binary should exist in local udf directory", localUdfDirPath.resolve(default_binary_name).toFile().exists());
assertTrue("Source should exist in local udf directory", localUdfDirPath.resolve(default_source_name).toFile().exists());
String summary = "The following UDFs in jar %s have been unregistered:\n" + "[custom_lower(VARCHAR-REQUIRED)]";
testBuilder().sqlQuery("drop function using jar '%s'", default_binary_name).unOrdered().baselineColumns("ok", "summary").baselineValues(true, String.format(summary, default_binary_name)).go();
try {
test("select custom_lower('A') from (values(1))");
} catch (UserRemoteException e) {
assertThat(e.getMessage(), containsString("No match found for function signature custom_lower(<CHARACTER>)"));
}
final RemoteFunctionRegistry remoteFunctionRegistry = getDrillbitContext().getRemoteFunctionRegistry();
final Path registryPath = hadoopToJavaPath(remoteFunctionRegistry.getRegistryArea());
assertEquals("Remote registry should be empty", remoteFunctionRegistry.getRegistry(new DataChangeVersion()).getJarList().size(), 0);
assertFalse("Binary should not be present in registry area", registryPath.resolve(default_binary_name).toFile().exists());
assertFalse("Source should not be present in registry area", registryPath.resolve(default_source_name).toFile().exists());
assertFalse("Binary should not be present in local udf directory", localUdfDirPath.resolve(default_binary_name).toFile().exists());
assertFalse("Source should not be present in local udf directory", localUdfDirPath.resolve(default_source_name).toFile().exists());
}
use of org.apache.drill.exec.store.sys.store.DataChangeVersion in project drill by axbaretto.
the class TestDynamicUDFSupport method testSuccessfulRegistration.
@Test
public void testSuccessfulRegistration() throws Exception {
copyDefaultJarsToStagingArea();
String summary = "The following UDFs in jar %s have been registered:\n" + "[custom_lower(VARCHAR-REQUIRED)]";
testBuilder().sqlQuery("create function using jar '%s'", default_binary_name).unOrdered().baselineColumns("ok", "summary").baselineValues(true, String.format(summary, default_binary_name)).go();
RemoteFunctionRegistry remoteFunctionRegistry = getDrillbitContext().getRemoteFunctionRegistry();
FileSystem fs = remoteFunctionRegistry.getFs();
assertFalse("Staging area should be empty", fs.listFiles(remoteFunctionRegistry.getStagingArea(), false).hasNext());
assertFalse("Temporary area should be empty", fs.listFiles(remoteFunctionRegistry.getTmpArea(), false).hasNext());
final Path path = hadoopToJavaPath(remoteFunctionRegistry.getRegistryArea());
assertTrue("Binary should be present in registry area", path.resolve(default_binary_name).toFile().exists());
assertTrue("Source should be present in registry area", path.resolve(default_source_name).toFile().exists());
Registry registry = remoteFunctionRegistry.getRegistry(new DataChangeVersion());
assertEquals("Registry should contain one jar", registry.getJarList().size(), 1);
assertEquals(registry.getJar(0).getName(), default_binary_name);
}
use of org.apache.drill.exec.store.sys.store.DataChangeVersion in project drill by axbaretto.
the class TestDynamicUDFSupport method testExceedRetryAttemptsDuringRegistration.
@Test
public void testExceedRetryAttemptsDuringRegistration() throws Exception {
final RemoteFunctionRegistry remoteFunctionRegistry = spyRemoteFunctionRegistry();
final Path registryPath = hadoopToJavaPath(remoteFunctionRegistry.getRegistryArea());
final Path stagingPath = hadoopToJavaPath(remoteFunctionRegistry.getStagingArea());
final Path tmpPath = hadoopToJavaPath(remoteFunctionRegistry.getTmpArea());
copyDefaultJarsToStagingArea();
doThrow(new VersionMismatchException("Version mismatch detected", 1)).when(remoteFunctionRegistry).updateRegistry(any(Registry.class), any(DataChangeVersion.class));
String summary = "Failed to update remote function registry. Exceeded retry attempts limit.";
testBuilder().sqlQuery("create function using jar '%s'", default_binary_name).unOrdered().baselineColumns("ok", "summary").baselineValues(false, summary).go();
verify(remoteFunctionRegistry, times(remoteFunctionRegistry.getRetryAttempts() + 1)).updateRegistry(any(Registry.class), any(DataChangeVersion.class));
assertTrue("Binary should be present in staging area", stagingPath.resolve(default_binary_name).toFile().exists());
assertTrue("Source should be present in staging area", stagingPath.resolve(default_source_name).toFile().exists());
assertTrue("Registry area should be empty", ArrayUtils.isEmpty(registryPath.toFile().listFiles()));
assertTrue("Temporary area should be empty", ArrayUtils.isEmpty(tmpPath.toFile().listFiles()));
assertEquals("Registry should be empty", remoteFunctionRegistry.getRegistry(new DataChangeVersion()).getJarList().size(), 0);
}
Aggregations