/*
* 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 2008-2009 Sun Microsystems, Inc.
* Portions copyright 2011-2014 ForgeRock AS
*/
/**
* This message is used by DS to confirm a RS he wants to connect to him (open
* a session):
* Handshake sequence between DS and RS is like this:
* DS --- ServerStartMsg ---> RS
* DS <--- ReplServerStartMsg --- RS
* DS --- StartSessionMsg ---> RS
* DS <--- TopologyMsg --- RS
*
* This message contains:
* - status: the status we are entering the topology with
* - referrals URLs: the referrals URLs we allow peer DSs to use to refer to
* our domain when needed.
*/
{
/** The list of referrals URLs to the sending DS. */
/** The initial status the DS starts with. */
/** Assured replication enabled on DS or not. */
private boolean assuredFlag;
/** DS assured mode (relevant if assured replication enabled). */
/** DS safe data level (relevant if assured mode is safe data). */
/**
* Creates a new StartSessionMsg 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.
*/
{
{
decode_V23(in);
}
else
{
}
}
/**
* Creates a new message with the given required parameters.
* @param status Status we are starting with
* @param referralsURLs Referrals URLs to be used by peer DSs
* @param assuredFlag If assured mode is enabled or not
* @param assuredMode Assured type
* @param safeDataLevel Assured mode safe data level
*/
{
this.assuredFlag = assuredFlag;
this.assuredMode = assuredMode;
this.safeDataLevel = safeDataLevel;
}
// ============
// Msg encoding
// ============
/** {@inheritDoc} */
{
{
return getBytes_V23();
}
else
{
return getBytes_V45(protocolVersion);
}
}
{
try
{
{
}
{
}
{
{
}
}
return byteBuilder.toByteArray();
}
catch (Exception e)
{
throw new RuntimeException(e);
}
}
private byte[] getBytes_V23()
{
/*
* The message is stored in the form:
* <message type><status><assured flag><assured mode><safe data level>
* <list of referrals urls>
* (each referral url terminates with 0)
*/
{
{
}
}
return builder.toByteArray();
}
// ============
// Msg decoding
// ============
{
try
{
{
throw new DataFormatException("input is not a valid "
+ getClass().getCanonicalName());
}
/*
status = ServerStatus.valueOf(asn1Reader.readOctetString().byteAt(0));
assuredFlag = (asn1Reader.readOctetString().byteAt(0) == 1);
assuredMode=AssuredMode.valueOf((asn1Reader.readOctetString().byteAt(0)));
safeDataLevel = asn1Reader.readOctetString().byteAt(0);
*/
while(asn1Reader.hasNextElement())
{
this.referralsURLs.add(s);
}
while(asn1Reader.hasNextElement())
{
this.eclIncludes.add(s);
}
{
while (asn1Reader.hasNextElement())
{
}
}
else
{
// Default to using the same set of attributes for deletes.
}
}
catch (Exception e)
{
throw new RuntimeException(e);
}
}
{
/*
* The message is stored in the form:
* <message type><status><assured flag><assured mode><safe data level>
* <list of referrals urls>
* (each referral url terminates with 0)
*/
if (msgType != MSG_TYPE_START_SESSION)
{
throw new DataFormatException(
}
{
}
}
/**
* Get the list of referrals URLs.
*
* @return The list of referrals URLs.
*/
{
return referralsURLs;
}
/**
* Get the status from this message.
* @return The status.
*/
{
return status;
}
/** {@inheritDoc} */
{
return "StartSessionMsg content:\nstatus: " + status +
"\nassuredFlag: " + assuredFlag +
"\nassuredMode: " + assuredMode +
"\nsafeDataLevel: " + safeDataLevel +
"\nreferralsURLs: " + urls +
"\nEclIncludes " + eclIncludes +
"\nEclIncludeForDeletes: " + eclIncludesForDeletes;
}
/**
* Returns true if assured mode is enabled.
* @return true if assured mode is enabled.
*/
public boolean isAssured()
{
return assuredFlag;
}
/**
* Get the assured mode.
* @return the assured mode.
*/
{
return assuredMode;
}
/**
* Get the safe data level.
* @return the safe data level.
*/
public byte getSafeDataLevel()
{
return safeDataLevel;
}
/**
* Set the attributes configured on a server to be included in the ECL.
*
* @param includeAttributes
* attributes to be included with all change records.
* @param includeAttributesForDeletes
* additional attributes to be included with delete change records.
*/
public void setEclIncludes(
{
if (includeAttributes != null)
{
}
if (includeAttributesForDeletes != null)
{
}
}
/**
* Get the attributes to include in each change for the ECL.
*
* @return The attributes to include in each change for the ECL.
*/
{
return eclIncludes;
}
/**
* Get the attributes to include in each delete change for the ECL.
*
* @return The attributes to include in each delete change for the ECL.
*/
{
return eclIncludesForDeletes;
}
}