use of org.apache.drill.exec.exception.VersionMismatchException in project drill by apache.
the class LocalPersistentStore method put.
@Override
public void put(String key, V value, DataChangeVersion dataChangeVersion) {
try (AutoCloseableLock lock = writeLock.open()) {
if (dataChangeVersion != null && dataChangeVersion.getVersion() != version) {
throw new VersionMismatchException("Version mismatch detected", dataChangeVersion.getVersion());
}
try (OutputStream os = fs.create(makePath(key))) {
IOUtils.write(config.getSerializer().serialize(value), os);
version++;
} catch (IOException e) {
throw new RuntimeException(e);
}
}
}
use of org.apache.drill.exec.exception.VersionMismatchException in project drill by apache.
the class NoWriteLocalStore method put.
@Override
public void put(final String key, final V value, final DataChangeVersion dataChangeVersion) {
try (AutoCloseableLock lock = writeLock.open()) {
if (dataChangeVersion != null && dataChangeVersion.getVersion() != version) {
throw new VersionMismatchException("Version mismatch detected", dataChangeVersion.getVersion());
}
store.put(key, value);
version++;
}
}
use of org.apache.drill.exec.exception.VersionMismatchException in project drill by axbaretto.
the class VersionedDelegatingStore method put.
@Override
public void put(final String key, final V value, final DataChangeVersion dataChangeVersion) {
try (@SuppressWarnings("unused") Closeable lock = writeLock.open()) {
if (dataChangeVersion.getVersion() != version) {
throw new VersionMismatchException("Version mismatch detected", dataChangeVersion.getVersion());
}
store.put(key, value);
version++;
}
}
use of org.apache.drill.exec.exception.VersionMismatchException 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);
}
use of org.apache.drill.exec.exception.VersionMismatchException in project drill by axbaretto.
the class TestDynamicUDFSupport method testSuccessfulUnregistrationAfterSeveralRetryAttempts.
@Test
public void testSuccessfulUnregistrationAfterSeveralRetryAttempts() throws Exception {
RemoteFunctionRegistry remoteFunctionRegistry = spyRemoteFunctionRegistry();
copyDefaultJarsToStagingArea();
test("create function using jar '%s'", default_binary_name);
reset(remoteFunctionRegistry);
doThrow(new VersionMismatchException("Version mismatch detected", 1)).doThrow(new VersionMismatchException("Version mismatch detected", 1)).doCallRealMethod().when(remoteFunctionRegistry).updateRegistry(any(Registry.class), any(DataChangeVersion.class));
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();
verify(remoteFunctionRegistry, times(3)).updateRegistry(any(Registry.class), any(DataChangeVersion.class));
FileSystem fs = remoteFunctionRegistry.getFs();
assertFalse("Registry area should be empty", fs.listFiles(remoteFunctionRegistry.getRegistryArea(), false).hasNext());
assertEquals("Registry should be empty", remoteFunctionRegistry.getRegistry(new DataChangeVersion()).getJarList().size(), 0);
}
Aggregations