TopologyMsg.java revision 07e7cb84f497a907074b5ca46f3147f65488d6ed
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at legal-notices/CDDLv1_0.txt.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information:
* Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*
*
* Copyright 2007-2010 Sun Microsystems, Inc.
* Portions Copyright 2011-2015 ForgeRock AS
*/
/**
* This class defines a message that is sent:
* - By a RS to the other RSs in the topology, containing:
* - the DSs directly connected to the RS in the DS infos
* - only this RS in the RS infos
* - By a RS to his connected DSs, containing every DSs and RSs he knows.
* In that case the message contains:
* - every DSs the RS knows except the destinator DS in the DS infos
* - every connected RSs (including the sending RS) in the RS infos
*
* Exchanging these messages allows to have each RS or DS take
* appropriate decisions according to the current topology:
* - a RS can route a message to a DS
* - a DS can decide towards which peer DS send referrals
* ...
*/
public class TopologyMsg extends ReplicationMsg
{
/** Information for the DSs (aka replicas) known in the topology. */
/** Information for the RSs known in the topology. */
/**
* Creates a new changelogInfo message from its encoded form.
*
* @param in The byte array containing the encoded form of the message.
* @param version The protocol version to use to decode the msg.
* @throws java.util.zip.DataFormatException If the byte array does not
* contain a valid encoded form of the message.
*/
{
if (msgType != MSG_TYPE_TOPOLOGY)
{
throw new DataFormatException("Input is not a valid "
+ getClass().getCanonicalName());
}
// Read the DS info entries, first read number of them
{
nDsInfo--;
}
// Read the RS info entries
{
nRsInfo--;
}
}
throws DataFormatException
{
short protocolVersion = -1;
if (version >= REPLICATION_PROTOCOL_V4)
{
if (version >= REPLICATION_PROTOCOL_V5)
{
}
else
{
// Default to using the same set of attributes for deletes.
}
}
}
throws DataFormatException
{
int weight = 1;
if (version >= REPLICATION_PROTOCOL_V4)
{
}
}
/**
* Creates a new message of the currently connected servers.
*
* @param dsInfos The collection of currently connected DS servers ID.
* @param rsInfos The list of currently connected RS servers ID.
*/
{
{
}
else
{
{
}
}
{
}
else
{
this.rsInfos =
}
}
// ============
// Msg encoding
// ============
/** {@inheritDoc} */
{
/**
* Message has the following form:
* <pdu type><number of following DSInfo entries>[<DSInfo>]*
* <number of following RSInfo entries>[<RSInfo>]*
*/
// Put DS infos
{
if (version >= REPLICATION_PROTOCOL_V6)
{
}
if (version >= REPLICATION_PROTOCOL_V4)
{
if (version >= REPLICATION_PROTOCOL_V5)
{
}
}
}
// Put RS infos
{
if (version >= REPLICATION_PROTOCOL_V4)
{
}
}
return builder.toByteArray();
}
/** {@inheritDoc} */
{
{
}
{
}
return "TopologyMsg content:"
+ "\n----------------------------"
+ "\nCONNECTED DS SERVERS:"
+ "\n--------------------\n"
+ dsStr
+ "CONNECTED RS SERVERS:"
+ "\n--------------------\n"
+ rsStr
}
/**
* Get the DS infos.
*
* @return The DS infos
*/
{
return replicaInfos;
}
/**
* Get the RS infos.
*
* @return The RS infos
*/
{
return rsInfos;
}
}