org.apache.kafka.connect.errors.IllegalWorkerStateException Java Examples
The following examples show how to use
org.apache.kafka.connect.errors.IllegalWorkerStateException.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AbstractPolicy.java From kafka-connect-fs with Apache License 2.0 | 6 votes |
@Override public final Iterator<FileMetadata> execute() throws IOException { if (hasEnded()) { throw new IllegalWorkerStateException("Policy has ended. Cannot be retried."); } preCheck(); executions.incrementAndGet(); Iterator<FileMetadata> files = Collections.emptyIterator(); for (FileSystem fs : fileSystems) { files = concat(files, listFiles(fs)); } postCheck(); return files; }
Example #2
Source File: PolicyTestBase.java From kafka-connect-fs with Apache License 2.0 | 5 votes |
@ParameterizedTest @MethodSource("fileSystemConfigProvider") public void execPolicyAlreadyEnded(PolicyFsTestConfig fsConfig) throws IOException { fsConfig.getPolicy().execute(); assertTrue(fsConfig.getPolicy().hasEnded()); assertThrows(IllegalWorkerStateException.class, () -> fsConfig.getPolicy().execute()); }
Example #3
Source File: HdfsFileWatcherPolicyTest.java From kafka-connect-fs with Apache License 2.0 | 5 votes |
@ParameterizedTest @MethodSource("fileSystemConfigProvider") @Override public void execPolicyAlreadyEnded(PolicyFsTestConfig fsConfig) throws IOException { fsConfig.getPolicy().execute(); assertFalse(fsConfig.getPolicy().hasEnded()); fsConfig.getPolicy().interrupt(); assertTrue(fsConfig.getPolicy().hasEnded()); assertThrows(IllegalWorkerStateException.class, () -> fsConfig.getPolicy().execute()); }
Example #4
Source File: CronPolicyTest.java From kafka-connect-fs with Apache License 2.0 | 5 votes |
@ParameterizedTest @MethodSource("fileSystemConfigProvider") @Override public void execPolicyAlreadyEnded(PolicyFsTestConfig fsConfig) throws IOException { fsConfig.getPolicy().execute(); fsConfig.getPolicy().interrupt(); assertTrue(fsConfig.getPolicy().hasEnded()); assertThrows(IllegalWorkerStateException.class, () -> fsConfig.getPolicy().execute()); }
Example #5
Source File: HdfsFileWatcherPolicy.java From kafka-connect-fs with Apache License 2.0 | 4 votes |
@Override public void run() { while (true) { try { DFSInotifyEventInputStream eventStream = admin.getInotifyEventStream(); if (fs.getFileStatus(fs.getWorkingDirectory()) != null && fs.exists(fs.getWorkingDirectory())) { EventBatch batch = eventStream.poll(); if (batch == null) continue; for (Event event : batch.getEvents()) { switch (event.getEventType()) { case CREATE: if (!((Event.CreateEvent) event).getPath().endsWith("._COPYING_")) { enqueue(((Event.CreateEvent) event).getPath()); } break; case APPEND: if (!((Event.AppendEvent) event).getPath().endsWith("._COPYING_")) { enqueue(((Event.AppendEvent) event).getPath()); } break; case RENAME: if (((Event.RenameEvent) event).getSrcPath().endsWith("._COPYING_")) { enqueue(((Event.RenameEvent) event).getDstPath()); } break; case CLOSE: if (!((Event.CloseEvent) event).getPath().endsWith("._COPYING_")) { enqueue(((Event.CloseEvent) event).getPath()); } break; default: break; } } } } catch (IOException ioe) { if (retrySleepMs > 0) { time.sleep(retrySleepMs); } else { log.warn("Error watching path [{}]. Stopping it...", fs.getWorkingDirectory(), ioe); throw new IllegalWorkerStateException(ioe); } } catch (Exception e) { log.warn("Stopping watcher due to an unexpected exception when watching path [{}].", fs.getWorkingDirectory(), e); throw new IllegalWorkerStateException(e); } } }