/** * utility/debug method. Use "asByteArray" for programmatic use as the * byte array will already by UTF-8 and ready to be sent on network. * * @param o * @return */ public String asJsonString(Object o) { if ( getCoderSpecific() instanceof JsonFactory == false ) { return "can be called on JsonConfiguration only"; } else { return new String(asByteArray(o), StandardCharsets.UTF_8); } }
public <T> T deepCopy(T metadata) { return (T) asObject(asByteArray(metadata)); }
public <T> T deepCopy(T metadata) { return (T) asObject(asByteArray(metadata)); }
/** * utility/debug method. Use "asByteArray" for programmatic use as the * byte array will already by UTF-8 and ready to be sent on network. * * @param o * @return */ public String asJsonString(Object o) { if ( getCoderSpecific() instanceof JsonFactory == false ) { return "can be called on JsonConfiguration only"; } else { return new String(asByteArray(o), StandardCharsets.UTF_8); } }
public static <T> byte[] serialize(T value) { return CONFIGURATION.asByteArray(value); }
@Override public byte[] serialize(Object obj) { if (obj == null) return null; return fst.asByteArray(obj); }
public void pack(FSTConfiguration conf) { if ( args != null && serializedArgs == null ) { if ( args.length > 0 && args[args.length-1] instanceof Callback ) { cb = (Callback) args[args.length-1]; args[args.length-1] = null; } serializedArgs = conf.asByteArray(args); args = null; } }
@Override public int serializedSize(E value) { return FST.asByteArray(value).length + Integer.BYTES; } }
public void pack(FSTConfiguration conf) { if ( args != null && serializedArgs == null ) { if ( args.length > 0 && args[args.length-1] instanceof Callback ) { cb = (Callback) args[args.length-1]; args[args.length-1] = null; } serializedArgs = conf.asByteArray(args); args = null; } }
@Override public byte[] serialize(Serializable object) throws IOException { try { return fst.asByteArray(object); } catch (Exception e) { logger.error("Exception while serializing object {}", object, e); throw e; } }
@Override public void serialize(E value, ByteBuffer buf) { byte[] array = FST.asByteArray(value); buf.putInt(array.length); buf.put(array); }
public IPromise longPoll() { int seq = sendSequence.incrementAndGet(); Object[] objArr = {seq}; return longPollSend(conf.asByteArray(objArr)); }
public static byte[] asByte(Object obj) { FSTConfiguration fst = getFST(); return fst.asByteArray(obj); }
@Override public void flush() throws Exception { synchronized (this) { if (objects.size() == 0) { return; } objects.add(sendSequence.incrementAndGet()); // sequence Object[] objArr = objects.toArray(); objects.clear(); sendBinary(conf.asByteArray(objArr)); } }
@Override public void putIfAbsent(Object key, Object value) { try { cache.put(fst.asByteArray(key), fst.asByteArray(value)); cacheStatistics.incPutTimes(); if (LOGGER.isDebugEnabled()) { LOGGER.debug(name + " add leveldb cache ,key:" + key + " value:" + value); } } catch (Exception e) { throw new RocksDBPoolException(e); } }
public void receiveCBResult(ObjectSocket chan, long id, Object result, Object error) { RemoteCallEntry rce = new RemoteCallEntry(0, id, null, null, conf.asByteArray(new Object[] {result,error})); rce.setQueue(rce.CBQ); rce.setContinue( error == Actors.CONT ); try { writeObject(chan, rce); } catch (Exception e) { e.printStackTrace(); } }
public void receiveCBResult(ObjectSocket chan, long id, Object result, Object error) { RemoteCallEntry rce = new RemoteCallEntry(0, id, null, null, conf.asByteArray(new Object[] {result,error})); rce.setQueue(rce.CBQ); rce.setContinue( error == Actors.CONT ); try { writeObject(chan, rce); } catch (Exception e) { e.printStackTrace(); } }
protected void sendFailoverNotificationInternal(ConnectionRegistry registry) { RemoteCallEntry rce = new RemoteCallEntry( 0, 0, "krouterTargetDidChange", null, registry.getConf().asByteArray(new Object[] {}) ); registry.inFacadeThread( () -> registry.forwardRemoteMessage(rce) ); }
/** * Creates an index entry for the given key of the form INDEXED_ENTRY_PREFIX + * primaryfiltername + primaryfiltervalue + key. */ private static byte[] addPrimaryFilterToKey(String primaryFilterName, Object primaryFilterValue, byte[] key) throws IOException { return KeyBuilder.newInstance().add(primaryFilterName) .add(fstConf.asByteArray(primaryFilterValue), true).add(key).getBytes(); }
@CallerSideMethod protected RemoteCallEntry createErrorPromiseResponse(RemoteCallEntry rce, ConnectionRegistry clientRemoteRegistry) { RemoteCallEntry cbrce = new RemoteCallEntry(); cbrce.setReceiverKey(rce.getFutureKey()); cbrce.setSerializedArgs(clientRemoteRegistry.getConf().asByteArray(new Object[]{null,SERVICE_UNAVAILABLE})); cbrce.setQueue(1); return cbrce; }