public ParentLastURLClassLoader(URL[] urls) { super(Thread.currentThread().getContextClassLoader()); childClassLoader = new ChildURLClassLoader(urls, new FindClassClassLoader(this.getParent())); }
public static void main(final String[] args) { System.exit(new StreamsResetter().run(args)); }
@Override protected synchronized Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException { try { // first we try to find a class inside the child class loader return childClassLoader.findClass(name); } catch( ClassNotFoundException e ) { // didn't find it, try the parent return super.loadClass(name, resolve); } } }
public int run(final String[] args) { return run(args, new Properties()); }
private Map<TopicPartition, Long> getTopicPartitionOffsetFromResetPlan(String resetPlanPath) throws IOException, ParseException { final String resetPlanCsv = Utils.readFileAsString(resetPlanPath); return parseResetPlan(resetPlanCsv); }
public void resetOffsetsFromResetPlan(Consumer<byte[], byte[]> client, Set<TopicPartition> inputTopicPartitions, Map<TopicPartition, Long> topicPartitionsAndOffset) { final Map<TopicPartition, Long> endOffsets = client.endOffsets(inputTopicPartitions); final Map<TopicPartition, Long> beginningOffsets = client.beginningOffsets(inputTopicPartitions); final Map<TopicPartition, Long> validatedTopicPartitionsAndOffset = checkOffsetRange(topicPartitionsAndOffset, beginningOffsets, endOffsets); for (final TopicPartition topicPartition : inputTopicPartitions) { client.seek(topicPartition, validatedTopicPartitionsAndOffset.get(topicPartition)); } }
@Override public void run() { try { ConsumerConnectorShutdownMethod_07.invoke(consumerConnector_07); } catch(Exception e) { logger.error("Error while shutting down Kafka consumer", e); } for(MigrationThread migrationThread : migrationThreads) { migrationThread.shutdown(); } for(ProducerThread producerThread : producerThreads) { producerThread.shutdown(); } for(ProducerThread producerThread : producerThreads) { producerThread.awaitShutdown(); } logger.info("Kafka migration tool shutdown successfully"); } });
public void shutdown() { try { logger.info("Producer thread " + threadName + " shutting down"); producerDataChannel.sendRequest(shutdownMessage); } catch(InterruptedException ie) { logger.warn("Interrupt during shutdown of ProducerThread", ie); } }
public ProducerThread(ProducerDataChannel<KeyedMessage<byte[], byte[]>> _producerDataChannel, Producer<byte[], byte[]> _producer, int _threadId) { producerDataChannel = _producerDataChannel; producer = _producer; threadId = _threadId; threadName = "ProducerThread-" + threadId; logger = org.apache.log4j.Logger.getLogger(ProducerThread.class.getName()); this.setName(threadName); }
MigrationThread(Object _stream, ProducerDataChannel<KeyedMessage<byte[], byte[]>> _producerDataChannel, int _threadId) { stream = _stream; producerDataChannel = _producerDataChannel; threadId = _threadId; threadName = "MigrationThread-" + threadId; logger = org.apache.log4j.Logger.getLogger(MigrationThread.class.getName()); this.setName(threadName); }
@Override public Class<?> findClass(String name) throws ClassNotFoundException { try{ // first try to use the URLClassLoader findClass return super.findClass(name); } catch( ClassNotFoundException e ) { // if that fails, we ask our real parent class loader to load the class (we give up) return realParent.loadClass(name); } } }
public static void main(final String[] args) { Exit.exit(new StreamsResetter().run(args)); }
public int run(final String[] args) { return run(args, new Properties()); }
private Map<TopicPartition, Long> getTopicPartitionOffsetFromResetPlan(String resetPlanPath) throws IOException, ParseException { final String resetPlanCsv = Utils.readFileAsString(resetPlanPath); return parseResetPlan(resetPlanCsv); }
public void resetOffsetsFromResetPlan(Consumer<byte[], byte[]> client, Set<TopicPartition> inputTopicPartitions, Map<TopicPartition, Long> topicPartitionsAndOffset) { final Map<TopicPartition, Long> endOffsets = client.endOffsets(inputTopicPartitions); final Map<TopicPartition, Long> beginningOffsets = client.beginningOffsets(inputTopicPartitions); final Map<TopicPartition, Long> validatedTopicPartitionsAndOffset = checkOffsetRange(topicPartitionsAndOffset, beginningOffsets, endOffsets); for (final TopicPartition topicPartition : inputTopicPartitions) { client.seek(topicPartition, validatedTopicPartitionsAndOffset.get(topicPartition)); } }
public static void main(final String[] args) { Exit.exit(new StreamsResetter().run(args)); }
public int run(final String[] args) { return run(args, new Properties()); }
private Map<TopicPartition, Long> getTopicPartitionOffsetFromResetPlan(String resetPlanPath) throws IOException, ParseException { final String resetPlanCsv = Utils.readFileAsString(resetPlanPath); return parseResetPlan(resetPlanCsv); }
public static void main(final String[] args) { Exit.exit(new StreamsResetter().run(args)); }
public int run(final String[] args) { return run(args, new Properties()); }