public static Counter allocate ( final Aeron aeron , final MutableDirectBuffer tempBuffer , final long leadershipTermId , final long logPosition , final long timestamp , final boolean hasReplay , final long ... snapshotRecordingIds ) { tempBuffer . putLong ( LEADERSHIP_TERM_ID_OFFSET , leadershipTermId ) ; tempBuffer . putLong ( LOG_POSITION_OFFSET , logPosition ) ; tempBuffer . putLong ( TIMESTAMP_OFFSET , timestamp ) ; tempBuffer . putInt ( REPLAY_FLAG_OFFSET , hasReplay ? 1 : 0 ) ; final int serviceCount = snapshotRecordingIds . length ; tempBuffer . putInt ( SERVICE_COUNT_OFFSET , serviceCount ) ; final int keyLength = SNAPSHOT_RECORDING_IDS_OFFSET + ( serviceCount * SIZE_OF_LONG ) ; if ( keyLength > MAX_KEY_LENGTH ) { throw new ClusterException ( keyLength + " exceeds max key length " + MAX_KEY_LENGTH ) ; } for ( int i = 0 ; i < serviceCount ; i ++ ) { tempBuffer . putLong ( SNAPSHOT_RECORDING_IDS_OFFSET + ( i * SIZE_OF_LONG ) , snapshotRecordingIds [ i ] ) ; } final int labelOffset = BitUtil . align ( keyLength , SIZE_OF_INT ) ; int labelLength = 0 ; labelLength += tempBuffer . putStringWithoutLengthAscii ( labelOffset + labelLength , NAME ) ; labelLength += tempBuffer . putLongAscii ( keyLength + labelLength , leadershipTermId ) ; labelLength += tempBuffer . putStringWithoutLengthAscii ( labelOffset + labelLength , " logPosition=" ) ; labelLength += tempBuffer . putLongAscii ( labelOffset + labelLength , logPosition ) ; labelLength += tempBuffer . putStringWithoutLengthAscii ( labelOffset + labelLength , " hasReplay=" + hasReplay ) ; return aeron . addCounter ( RECOVERY_STATE_TYPE_ID , tempBuffer , 0 , keyLength , tempBuffer , labelOffset , labelLength ) ; }
Allocate a counter to represent the snapshot services should load on start .