Search in sources :

Example 1 with MtpException

use of org.iplass.mtp.MtpException in project iPLAss by ISID.

the class RedisCacheStoreFactory method inited.

@Override
public void inited(CacheService service, Config config) {
    RedisService rs = config.getDependentService(RedisService.class);
    server = rs.getRedisServer(serverName);
    if (server == null) {
        throw new MtpException("Unknown redis server name: " + serverName);
    }
    ClientResources resouces = DefaultClientResources.builder().build();
    RedisURI.Builder uriBuilder = RedisURI.builder().withHost(server.getHost()).withPort(server.getPort());
    if (server.getTimeout() > 0) {
        uriBuilder.withTimeout(Duration.ofSeconds(server.getTimeout()));
    }
    client = RedisClient.create(resouces, uriBuilder.build());
}
Also used : MtpException(org.iplass.mtp.MtpException) ClientResources(io.lettuce.core.resource.ClientResources) DefaultClientResources(io.lettuce.core.resource.DefaultClientResources) RedisURI(io.lettuce.core.RedisURI) RedisService(org.iplass.mtp.impl.redis.RedisService)

Example 2 with MtpException

use of org.iplass.mtp.MtpException in project iPLAss by ISID.

the class RedisCacheStoreBase method encodeBase64.

protected String encodeBase64(Object obj) {
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    try (ObjectOutputStream bis = new ObjectOutputStream(baos)) {
        bis.writeObject(obj);
        bis.flush();
        return Base64.getEncoder().encodeToString(baos.toByteArray());
    } catch (IOException e) {
        throw new MtpException(e);
    }
}
Also used : MtpException(org.iplass.mtp.MtpException) ByteArrayOutputStream(java.io.ByteArrayOutputStream) IOException(java.io.IOException) ObjectOutputStream(java.io.ObjectOutputStream)

Aggregations

MtpException (org.iplass.mtp.MtpException)2 RedisURI (io.lettuce.core.RedisURI)1 ClientResources (io.lettuce.core.resource.ClientResources)1 DefaultClientResources (io.lettuce.core.resource.DefaultClientResources)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 IOException (java.io.IOException)1 ObjectOutputStream (java.io.ObjectOutputStream)1 RedisService (org.iplass.mtp.impl.redis.RedisService)1