public TokyoTyrantTranscoder() { serializingTranscoder = new SerializingTranscoder(); serializingTranscoder.setPackZeros(false); }
int flags = 0; if (o instanceof String) { b = encodeString((String) o); } else if (o instanceof Long) { if (this.primitiveAsString) { b = encodeString(o.toString()); } else { b = this.transcoderUtils.encodeLong((Long) o); } else if (o instanceof Integer) { if (this.primitiveAsString) { b = encodeString(o.toString()); } else { b = this.transcoderUtils.encodeInt((Integer) o); } else if (o instanceof Boolean) { if (this.primitiveAsString) { b = encodeString(o.toString()); } else { b = this.transcoderUtils.encodeBoolean((Boolean) o); } else if (o instanceof Byte) { if (this.primitiveAsString) { b = encodeString(o.toString()); } else { b = this.transcoderUtils.encodeByte((Byte) o); } else if (o instanceof Float) { if (this.primitiveAsString) {
public final Object decode(CachedData d) { byte[] compositeData = d.getData(); if (compositeData.length <= 4) throw new MemcachedDecodeException( "There are no four bytes before value for TokyoTyrantTranscoder"); byte[] flagBytes = new byte[4]; byte[] realData = new byte[compositeData.length - 4]; System.arraycopy(compositeData, 0, flagBytes, 0, 4); System.arraycopy(compositeData, 4, realData, 0, compositeData.length - 4); int flag = serializingTranscoder.getTranscoderUtils().decodeInt(flagBytes); d.setFlag(flag); if ((flag & SerializingTranscoder.COMPRESSED) != 0) { realData = serializingTranscoder.decompress(realData); } flag = flag & SerializingTranscoder.SPECIAL_MASK; return serializingTranscoder.decode0(d, realData, flag); }
public final Object decode(CachedData d) { Object obj = d.decodedObject; if (obj != null) { return obj; } byte[] data = d.data; int flags = d.flag; if ((flags & COMPRESSED) != 0) { data = decompress(data); } flags = flags & SPECIAL_MASK; obj = decode0(d, data, flags); d.decodedObject = obj; return obj; }
/** * XMemcached Constructor. * * @param inetSocketAddress * @param weight * @throws IOException */ public XMemcachedClient(final InetSocketAddress inetSocketAddress, int weight, CommandFactory cmdFactory) throws IOException { super(); if (inetSocketAddress == null) { throw new IllegalArgumentException("Null InetSocketAddress"); } if (cmdFactory == null) { throw new IllegalArgumentException("Null command factory."); } if (weight <= 0) { throw new IllegalArgumentException("weight<=0"); } this.buildConnector(new ArrayMemcachedSessionLocator(), new SimpleBufferAllocator(), XMemcachedClientBuilder.getDefaultConfiguration(), XMemcachedClientBuilder.getDefaultSocketOptions(), cmdFactory, new SerializingTranscoder()); this.start0(); this.connect(new InetSocketAddressWrapper(inetSocketAddress, this.serverOrderCount.incrementAndGet(), weight, null)); }
public final CachedData encode(Object o) { CachedData result = serializingTranscoder.encode(o); byte[] realData = result.getData(); int flag = result.getFlag(); byte[] flagBytes = serializingTranscoder.getTranscoderUtils().encodeInt(flag); byte[] compisiteData = new byte[4 + realData.length]; System.arraycopy(flagBytes, 0, compisiteData, 0, 4); System.arraycopy(realData, 0, compisiteData, 4, realData.length); result.setData(compisiteData); return result; }
protected final Object decode0(CachedData cachedData, byte[] data, int flags) { Object rv = null; if ((cachedData.flag & SERIALIZED) != 0 && data != null) { rv = deserialize(data); } else { if (this.primitiveAsString) { if (flags == 0) { return decodeString(data); rv = decodeString(data);
/** * XMemcached Constructor.Every server's weight is one by default. * * @param cmdFactory command factory * @param addressList memcached server socket address list. * @throws IOException */ public XMemcachedClient(List<InetSocketAddress> addressList, CommandFactory cmdFactory) throws IOException { super(); if (cmdFactory == null) { throw new IllegalArgumentException("Null command factory."); } if (addressList == null || addressList.isEmpty()) { throw new IllegalArgumentException("Empty address list"); } BufferAllocator simpleBufferAllocator = new SimpleBufferAllocator(); this.buildConnector(new ArrayMemcachedSessionLocator(), simpleBufferAllocator, XMemcachedClientBuilder.getDefaultConfiguration(), XMemcachedClientBuilder.getDefaultSocketOptions(), cmdFactory, new SerializingTranscoder()); this.start0(); for (InetSocketAddress inetSocketAddress : addressList) { this.connect(new InetSocketAddressWrapper(inetSocketAddress, this.serverOrderCount.incrementAndGet(), 1, null)); } }
public final CachedData encode(Object o) { CachedData result = serializingTranscoder.encode(o); byte[] realData = result.getData(); int flag = result.getFlag(); byte[] flagBytes = serializingTranscoder.getTranscoderUtils().encodeInt(flag); byte[] compisiteData = new byte[4 + realData.length]; System.arraycopy(flagBytes, 0, compisiteData, 0, 4); System.arraycopy(realData, 0, compisiteData, 4, realData.length); result.setData(compisiteData); return result; }
public final Object decode(CachedData d) { Object obj = d.decodedObject; if (obj != null) { return obj; } byte[] data = d.data; int flags = d.flag; if ((flags & COMPRESSED) != 0) { data = decompress(data); } flags = flags & SPECIAL_MASK; obj = decode0(d, data, flags); d.decodedObject = obj; return obj; }
protected final Object decode0(CachedData cachedData, byte[] data, int flags) { Object rv = null; if ((cachedData.flag & SERIALIZED) != 0 && data != null) { rv = deserialize(data); } else { if (this.primitiveAsString) { if (flags == 0) { return decodeString(data); rv = decodeString(data);
/** * Construct an AWSElasticCacheClient instance with config server addresses. * * @since 2.3.0 * @param addrs config server list. * @param pollConfigIntervalMills config poll interval in milliseconds. * @param commandFactory protocol command factory. * @throws IOException */ @SuppressWarnings("unchecked") public AWSElasticCacheClient(List<InetSocketAddress> addrs, long pollConfigIntervalMills, CommandFactory commandFactory) throws IOException { this(new ArrayMemcachedSessionLocator(), new SimpleBufferAllocator(), XMemcachedClientBuilder.getDefaultConfiguration(), XMemcachedClientBuilder.getDefaultSocketOptions(), new TextCommandFactory(), new SerializingTranscoder(), (List<MemcachedClientStateListener>) Collections.EMPTY_LIST, (Map<InetSocketAddress, AuthInfo>) Collections.EMPTY_MAP, 1, XMemcachedClient.DEFAULT_CONNECT_TIMEOUT, null, true, addrs, pollConfigIntervalMills); }
public TokyoTyrantTranscoder(int maxSize) { serializingTranscoder = new SerializingTranscoder(maxSize); serializingTranscoder.setPackZeros(false); }
public final Object decode(CachedData d) { byte[] compositeData = d.getData(); if (compositeData.length <= 4) throw new MemcachedDecodeException( "There are no four bytes before value for TokyoTyrantTranscoder"); byte[] flagBytes = new byte[4]; byte[] realData = new byte[compositeData.length - 4]; System.arraycopy(compositeData, 0, flagBytes, 0, 4); System.arraycopy(compositeData, 4, realData, 0, compositeData.length - 4); int flag = serializingTranscoder.getTranscoderUtils().decodeInt(flagBytes); d.setFlag(flag); if ((flag & SerializingTranscoder.COMPRESSED) != 0) { realData = serializingTranscoder.decompress(realData); } flag = flag & SerializingTranscoder.SPECIAL_MASK; return serializingTranscoder.decode0(d, realData, flag); }
int flags = 0; if (o instanceof String) { b = encodeString((String) o); } else if (o instanceof Long) { if (this.primitiveAsString) { b = encodeString(o.toString()); } else { b = this.transcoderUtils.encodeLong((Long) o); } else if (o instanceof Integer) { if (this.primitiveAsString) { b = encodeString(o.toString()); } else { b = this.transcoderUtils.encodeInt((Integer) o); } else if (o instanceof Boolean) { if (this.primitiveAsString) { b = encodeString(o.toString()); } else { b = this.transcoderUtils.encodeBoolean((Boolean) o); } else if (o instanceof Byte) { if (this.primitiveAsString) { b = encodeString(o.toString()); } else { b = this.transcoderUtils.encodeByte((Byte) o); } else if (o instanceof Float) { if (this.primitiveAsString) {
public XMemcachedClient() throws IOException { super(); this.buildConnector(new ArrayMemcachedSessionLocator(), new SimpleBufferAllocator(), XMemcachedClientBuilder.getDefaultConfiguration(), XMemcachedClientBuilder.getDefaultSocketOptions(), new TextCommandFactory(), new SerializingTranscoder()); this.start0(); }
public TokyoTyrantTranscoder(int maxSize) { serializingTranscoder = new SerializingTranscoder(maxSize); serializingTranscoder.setPackZeros(false); }
/** * XMemcached constructor * * @param host server host * @param port server port * @param weight server weight * @throws IOException */ public XMemcachedClient(final String host, final int port, int weight) throws IOException { super(); if (weight <= 0) { throw new IllegalArgumentException("weight<=0"); } this.checkServerPort(host, port); this.buildConnector(new ArrayMemcachedSessionLocator(), new SimpleBufferAllocator(), XMemcachedClientBuilder.getDefaultConfiguration(), XMemcachedClientBuilder.getDefaultSocketOptions(), new TextCommandFactory(), new SerializingTranscoder()); this.start0(); this.connect(new InetSocketAddressWrapper(this.newSocketAddress(host, port), this.serverOrderCount.incrementAndGet(), weight, null)); }
public TokyoTyrantTranscoder() { serializingTranscoder = new SerializingTranscoder(); serializingTranscoder.setPackZeros(false); }
transcoder = new SerializingTranscoder();