public void write ( JsonGenerator jsonGenerator ) throws IOException { jsonGenerator . writeStartObject ( ) ; jsonGenerator . writeStringField ( "handle" , handle ) ; jsonGenerator . writeStringField ( "host" , host ) ; jsonGenerator . writeNumberField ( "port" , port ) ; jsonGenerator . writeNumberField ( "numPendingCalls" , pendingCalls . size ( ) ) ; jsonGenerator . writeFieldName ( "pendingCalls" ) ; jsonGenerator . writeStartArray ( ) ; for ( TBase call : pendingCalls ) { jsonGenerator . writeStartObject ( ) ; // TBase is an abstract class. While reading back, we want to know // what kind of object we actually wrote. Jackson does provide two methods // to do it automatically, but one of them adds types at a lot of places // where we don't need it, and hence our parsing would be required to be // changed. The other required adding an annotation to the TBase class, // which we can't do, since it is auto-generated by Thrift. String callType = call . getClass ( ) . getName ( ) ; jsonGenerator . writeStringField ( "callType" , callType ) ; jsonGenerator . writeObjectField ( "call" , call ) ; jsonGenerator . writeEndObject ( ) ; } jsonGenerator . writeEndArray ( ) ; jsonGenerator . writeEndObject ( ) ; }
Used to write the state of the SessionNotificationCtx instance to disk when we are persisting the state of the ClusterManager