Comments (4)
@btiernay thanks for sharing your solution, it really helped me out.
from kafka-storm-starter.
This is a known issue because Apache Commons' pool implementation is not serializable.
Here's my comment from the link above:
This serialization issue is similar to the issue described at dbpedia/distributed-extraction-framework#9. It looks as if one would need to use a different object pool implementation than the one from Apache Commons Pool, as the latter may be hard to serialize (see sparkContext broadcast JedisPool not work).
Furthermore I noticed that the serialization issue is also triggered locally (e.g. when running ./sbt test
in kafka-storm-starter) when using Spark 1.2+.
To fix this issue you need to implement your own, serializable pool.
from kafka-storm-starter.
I understand why it happens, but I did't know that is known issue.
I want to implement own pool, but I have some concerns about partitions and offsets.
from kafka-storm-starter.
I did something like the following for Java:
import static lombok.AccessLevel.PRIVATE;
import java.io.Serializable;
import java.util.NoSuchElementException;
import lombok.Getter;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
import lombok.experimental.Accessors;
import org.apache.commons.pool2.ObjectPool;
@RequiredArgsConstructor
public abstract class LazySerializableObjectPool<T> implements ObjectPool<T>, Serializable {
@NonNull
@Getter(lazy = true, value = PRIVATE)
@Accessors(fluent = true)
private final transient ObjectPool<T> delegate = createDelegate();
protected abstract ObjectPool<T> createDelegate();
@Override
public T borrowObject() throws Exception, NoSuchElementException, IllegalStateException {
return delegate().borrowObject();
}
@Override
public void returnObject(T obj) throws Exception {
delegate().returnObject(obj);
}
@Override
public void invalidateObject(T obj) throws Exception {
delegate().invalidateObject(obj);
}
@Override
public void addObject() throws Exception, IllegalStateException, UnsupportedOperationException {
delegate().addObject();
}
@Override
public int getNumIdle() {
return delegate().getNumIdle();
}
@Override
public int getNumActive() {
return delegate().getNumActive();
}
@Override
public void clear() throws Exception, UnsupportedOperationException {
delegate().clear();
}
@Override
public void close() {
delegate().close();
}
}
@RequiredArgsConstructor
public class KafkaProducerObjectPool extends LazySerializableObjectPool<...> {
/**
* Configuration.
*/
@NonNull
private final Map<String, String> producerProperties;
@Override
protected ObjectPool<KafkaProducer> createDelegate() {
val pooledObjectFactory = ...
val maxNumProducers = 10;
val poolConfig = new GenericObjectPoolConfig();
poolConfig.setMaxTotal(maxNumProducers);
poolConfig.setMaxIdle(maxNumProducers);
return new GenericObjectPool<KafkaProducer>(pooledObjectFactory, poolConfig);
}
}
See https://projectlombok.org/features/GetterLazy.html for details.
from kafka-storm-starter.
Related Issues (12)
- KafkaStormSpec Fails on AvroScheme[T] and AvroDecoderBolt[T] features HOT 16
- Failed to execute goal on project streams-examples HOT 1
- Failed to run "sbt test" HOT 3
- java.lang.UnsatisfiedLinkError
- org.eclipse.aether.resolution.ArtifactResolutionException:
- Weird NoRouteToHostException trying to run the tests HOT 2
- KafkaSparkStreamingSpec testsuite does not pass. HOT 2
- Storm UI showing improper values for Kafka Trident HOT 6
- we have setup all the tunning params for kafka and strom still getting very high latency HOT 1
- Test suit doesn't pass HOT 6
- User creates a Storm topology that uses AvroScheme in Kafka spout *** FAILED *** HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from kafka-storm-starter.