public ConfigChange(String attr_name, Object val) throws Exception { this.attr_name=attr_name; this.attr_value=Util.objectToByteBuffer(val); }
public ConfigChange(String attr_name, Object val) throws Exception { this.attr_name=attr_name; this.attr_value=Util.objectToByteBuffer(val); }
public static void writeObject(Object obj,DataOutput out) throws Exception { if(obj instanceof Streamable) { out.writeInt(-1); writeGenericStreamable((Streamable)obj,out); } else { byte[] buf=objectToByteBuffer(obj); out.writeInt(buf.length); out.write(buf,0,buf.length); } }
void sendDiscoveryRequest() { DiscoveryRequest req; byte[] buf; DatagramPacket packet; req = new DiscoveryRequest(local_addr, local_port); System.out.println("--> " + req); try { buf = Util.objectToByteBuffer(req); packet = new DatagramPacket(buf, buf.length, mcast_addr, mcast_port); mcast_sock.send(packet); } catch (Exception ex) { System.err.println("McastDiscovery.sendDiscoveryRequest(): " + ex); } }
public void writeTo(DataOutput out) throws Exception { out.writeByte(type.ordinal()); // We can't use Util.writeObject since it's size is limited to 2^15-1 try { if (object instanceof Streamable) { out.writeShort(-1); Util.writeGenericStreamable((Streamable)object, out); } else { byte[] bytes = Util.objectToByteBuffer(object); out.writeInt(bytes.length); out.write(bytes); } } catch (IOException e) { throw e; } catch (Exception e) { throw new IOException("Exception encountered while serializing execution request", e); } out.writeLong(request); }
public void run() { while (running) { buf = new byte[16000]; mcast_packet = new DatagramPacket(buf, buf.length); try { mcast_sock.receive(mcast_packet); req = (DiscoveryRequest) Util.objectFromByteBuffer(mcast_packet.getData()); System.out.println("<-- " + req); // send response back to req.sender_addr rsp = new DiscoveryResponse(new InetSocketAddress(local_addr, local_port), req.sender_addr.getAddress()); buf = Util.objectToByteBuffer(rsp); rsp_packet = new DatagramPacket(buf, buf.length, req.sender_addr); sock.send(rsp_packet); } catch (Exception ex) { System.err.println("McastReceiver.run(): " + ex + ", rsp_packet=" + rsp_packet.getSocketAddress() + ", length=" + rsp_packet.getLength() + " bytes"); ex.printStackTrace(); } } } }
/** * Takes an object and uses Java serialization to generate the byte[] buffer which is set in the * message. Parameter 'obj' has to be serializable (e.g. implementing Serializable, * Externalizable or Streamable, or be a basic type (e.g. Integer, Short etc)). */ public Message setObject(Object obj) { if(obj == null) return this; if(obj instanceof byte[]) return setBuffer((byte[])obj); if(obj instanceof Buffer) return setBuffer((Buffer)obj); try { return setBuffer(Util.objectToByteBuffer(obj)); } catch(Exception ex) { throw new IllegalArgumentException(ex); } }
public byte[] getState() { try { return Util.objectToByteBuffer(history); } catch(Exception e) { return null; } }
public static long sizeOf(Object inst) { byte[] data; try { data=Util.objectToByteBuffer(inst); return data.length; } catch(Exception ex) { return -1; } }
public ConfigChange(String attr_name, Object val) throws Exception { this.attr_name=attr_name; this.attr_value=Util.objectToByteBuffer(val); }
public byte[] getState() { // return the copy previously saved by saveState() try { return Util.objectToByteBuffer(copy); } catch(Throwable ex) { ex.printStackTrace(); return null; } }
public byte[] getState() { byte[] retval=null; if(state == null) return null; synchronized(state) { try { retval=Util.objectToByteBuffer(state); } catch(Exception e) { e.printStackTrace(); } } return retval; }
public byte[] getState() { try { return Util.objectToByteBuffer(stocks.clone()); } catch(Exception ex) { ex.printStackTrace(); return null; } }
/** Return a copy of the current cache (tree) */ public byte[] getState() { try { return Util.objectToByteBuffer(root.clone()); } catch(Throwable ex) { if(log.isErrorEnabled()) log.error("exception returning cache: " + ex); return null; } }
public byte[] getState() { Vector copy = (Vector)getContents().clone(); try { return Util.objectToByteBuffer(copy); } catch (Throwable ex) { logger.error("DistributedQueue.getState(): exception marshalling state.", ex); return null; } }
/** Return a copy of the tree */ public byte[] getState() { Object copy=root != null? root.copy() : null; try { return Util.objectToByteBuffer(copy); } catch(Throwable ex) { if(log.isErrorEnabled()) log.error("exception marshalling state: " + ex); return null; } }
public static void writeObject(Object obj, DataOutputStream out) throws Exception { if(obj == null || !(obj instanceof Streamable)) { byte[] buf=objectToByteBuffer(obj); out.writeShort(buf.length); out.write(buf, 0, buf.length); } else { out.writeShort(-1); writeGenericStreamable((Streamable)obj, out); } }
public static long sizeOf(String classname) { Object inst; byte[] data; try { inst=Util.loadClass(classname, null).newInstance(); data=Util.objectToByteBuffer(inst); return data.length; } catch(Exception ex) { return -1; } }
public static void writeObject(Object obj,DataOutput out) throws Exception { if(obj instanceof Streamable) { out.writeInt(-1); writeGenericStreamable((Streamable)obj,out); } else { byte[] buf=objectToByteBuffer(obj); out.writeInt(buf.length); out.write(buf,0,buf.length); } }
private void sendServiceState() throws Exception { byte[] data=Util.objectToByteBuffer(new HashSet<String>(services.keySet())); sendServiceMessage(ServiceInfo.LIST_SERVICES_RSP, null, channel.getLocalAddress(), true, data); }