}
}
private void getStateInternal(OutputStream stream) throws IOException
{
MarshalledValueOutputStream mvos = null; // don't create until we know we need it
for (Map.Entry<String, HAPartitionStateTransfer> entry: this.stateHandlers.entrySet())
{
HAPartitionStateTransfer subscriber = entry.getValue();
this.log.debug("getState for " + entry.getKey());
Object state = subscriber.getCurrentState();
if (state != null)
{
if (mvos == null)
{
// This is our first write, so need to write the header first
stream.write(SERIALIZABLE_VALUE);
mvos = new MarshalledValueOutputStream(stream);
}
mvos.writeObject(entry.getKey());
mvos.writeObject(state);
}
}
if (mvos == null)
{
// We never wrote any serviceState, so write the NULL header
stream.write(NULL_VALUE);
}
else
{
mvos.writeObject(new StateStreamEnd());
mvos.flush();
mvos.close();
}
}