com.esotericsoftware.kryo.pool.KryoPool Java Examples

The following examples show how to use com.esotericsoftware.kryo.pool.KryoPool. 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: KryoSerializer.java    From journalkeeper with Apache License 2.0 5 votes vote down vote up
public KryoSerializer(Class<T> type) {
    this.type = type;
    this.kryoPool = new KryoPool.Builder(() -> {
        Kryo kryo = new Kryo();
        if (type != null) {
            kryo.register(type);
        }
        return kryo;
    }).build();
}
 
Example #2
Source File: KryoUtils.java    From reef with Apache License 2.0 5 votes vote down vote up
@Inject
private KryoUtils() {
  final KryoFactory factory = new KryoFactory() {
    @Override
    public Kryo create() {
      final Kryo kryo = new Kryo();
      UnmodifiableCollectionsSerializer.registerSerializers(kryo); // Required to serialize/deserialize Throwable
      return kryo;
    }
  };
  kryoPool = new KryoPool.Builder(factory).softReferences().build();
}
 
Example #3
Source File: DefaultKryoContext.java    From AutoLoadCache with Apache License 2.0 5 votes vote down vote up
private DefaultKryoContext() {
    registrations = new ArrayList<>();

    //KryoFactory的create方法会延后调用
    pool = new KryoPool.Builder(() -> {
        Kryo kryo = new Kryo();
        registrations.forEach(reg -> reg.register(kryo));
        return kryo;
    }).softReferences().build();
}
 
Example #4
Source File: KryoSerializerFactory.java    From Thunder with Apache License 2.0 5 votes vote down vote up
public static KryoPool createPool(final int maxDepth) {
    return new KryoPool.Builder(new KryoFactory() {
        @Override
        public Kryo create() {
            return createKryo(maxDepth);
        }
    }).softReferences().build();
}
 
Example #5
Source File: KryoPoolFactory.java    From Raincat with GNU Lesser General Public License v3.0 5 votes vote down vote up
public static KryoPool getKryoPoolInstance() {
    if (poolFactory == null) {
        synchronized (KryoPoolFactory.class) {
            if (poolFactory == null) {
                poolFactory = new KryoPoolFactory();
            }
        }
    }
    return poolFactory.getPool();
}
 
Example #6
Source File: KryoSerializer.java    From journalkeeper with Apache License 2.0 5 votes vote down vote up
public KryoSerializer(Class<T> type) {
    this.type = type;
    this.kryoPool = new KryoPool.Builder(() -> {
        Kryo kryo = new Kryo();
        if (type != null) {
            kryo.register(type);
        }
        return kryo;
    }).build();
}
 
Example #7
Source File: KryoPoolFactory.java    From Lottor with MIT License 5 votes vote down vote up
public static KryoPool getKryoPoolInstance() {
    if (poolFactory == null) {
        synchronized (KryoPoolFactory.class) {
            if (poolFactory == null) {
                poolFactory = new KryoPoolFactory();
            }
        }
    }
    return poolFactory.getPool();
}
 
Example #8
Source File: KryoPoolFactory.java    From AvatarMQ with Apache License 2.0 4 votes vote down vote up
public static KryoPool getKryoPoolInstance() {
    return poolFactory.getPool();
}
 
Example #9
Source File: PooledKryoFactory.java    From dubbo-2.6.5 with Apache License 2.0 4 votes vote down vote up
public PooledKryoFactory() {
    // Build pool with SoftReferences enabled (optional)
    pool = new KryoPool.Builder(this).softReferences().build();
}
 
Example #10
Source File: KryoUtil.java    From archie with Apache License 2.0 4 votes vote down vote up
public static KryoPool getPool() {
    return pool;
}
 
Example #11
Source File: KryoSerializerFactory.java    From Thunder with Apache License 2.0 4 votes vote down vote up
public static KryoPool getDefaultPool() {
    return pool;
}
 
Example #12
Source File: KryoSerializerFactory.java    From Thunder with Apache License 2.0 4 votes vote down vote up
public static KryoPool createPool() {
    return createPool(KryoConstants.MAX_DEPTH);
}
 
Example #13
Source File: KryoSerialize.java    From AvatarMQ with Apache License 2.0 4 votes vote down vote up
public KryoSerialize(final KryoPool pool) {
    this.pool = pool;
}
 
Example #14
Source File: KryoCodecUtil.java    From AvatarMQ with Apache License 2.0 4 votes vote down vote up
public KryoCodecUtil(KryoPool pool) {
    this.pool = pool;
}
 
Example #15
Source File: KryoPoolFactory.java    From AvatarMQ with Apache License 2.0 4 votes vote down vote up
public KryoPool getPool() {
    return pool;
}
 
Example #16
Source File: KryoCodecServiceImpl.java    From Lottor with MIT License 4 votes vote down vote up
public KryoCodecServiceImpl(KryoPool pool) {
    this.pool = pool;
}
 
Example #17
Source File: PooledKryoFactory.java    From JobX with Apache License 2.0 4 votes vote down vote up
public PooledKryoFactory() {
    // Build pool with SoftReferences enabled (optional)
    pool = new KryoPool.Builder(this).softReferences().build();
}
 
Example #18
Source File: MessageEncoder.java    From lionrpc with Apache License 2.0 4 votes vote down vote up
public MessageEncoder(Class<?> clazz){
    this.clazz = clazz;
    pool = new KryoPool.Builder(new MyKryoFactory()).build();
}
 
Example #19
Source File: MessageDecoder.java    From lionrpc with Apache License 2.0 4 votes vote down vote up
public MessageDecoder(Class<?> clazz){
    this.clazz = clazz;
    pool = new KryoPool.Builder(new MyKryoFactory()).build();
}
 
Example #20
Source File: KryoSerialize.java    From Raincat with GNU Lesser General Public License v3.0 4 votes vote down vote up
public KryoSerialize(final KryoPool pool) {
    this.pool = pool;
}
 
Example #21
Source File: KryoCodecServiceImpl.java    From Raincat with GNU Lesser General Public License v3.0 4 votes vote down vote up
public KryoCodecServiceImpl(final KryoPool pool) {
    this.pool = pool;
}
 
Example #22
Source File: KryoPoolFactory.java    From Raincat with GNU Lesser General Public License v3.0 4 votes vote down vote up
public KryoPool getPool() {
    return pool;
}
 
Example #23
Source File: KryoPoolFactory.java    From Lottor with MIT License 4 votes vote down vote up
public KryoPool getPool() {
    return pool;
}
 
Example #24
Source File: KryoSerialize.java    From Lottor with MIT License 4 votes vote down vote up
public KryoSerialize(final KryoPool pool) {
    this.pool = pool;
}