public class JSpaceUtilities extends Object
Modifier and Type | Field and Description |
---|---|
static String |
BLANK_VALUE |
static String |
LINE_SEPARATOR |
static String |
NO_VAL |
static String |
NOT_AVAILABLE_STR |
static String |
SECURED_HIDDEN_VALUE |
static String |
YES_VAL |
Constructor and Description |
---|
JSpaceUtilities() |
Modifier and Type | Method and Description |
---|---|
static Document |
buildClusterXMLDom(int _totalMembers,
int _backupMembers,
String _clusterSchemaName,
String _clusterName,
String _distCacheConfigName,
String _jmsConfigName,
String _groups)
Builds a schema cluster config xml file on the fly, using several inputs.
|
static void |
convertDOMTreeFromSystemProperty(Node node)
Converts recursively entire DOM tree values from System Property to value.
|
static Document |
convertToClusterConfiguration(Document clusterXMLDomElement,
InputStream clusterXSLPolicy)
Method which gets cluster xml Dom element and cluster xsl schema input stream.
|
static long |
countSpaceObjects(SpaceRuntimeInfo info) |
static String |
createContainerPresentName(String hostName,
String containerName)
This method constructs name for container representation.
|
static String |
createFullSpaceName(String containerName,
String spaceName)
Create full space name based on container nadm and space name
|
static ProxyInternalSpaceException |
createProxyInternalSpaceException(Exception e) |
static String |
createServiceName(String serviceType,
int agentID,
long pid) |
static String |
createServiceName(String serviceType,
int agentID,
long pid,
String[] zones) |
static boolean |
domWriter(Node node,
PrintStream ps,
String prefix)
Order all XML tags of DOM tree and writes XML DOM tree to OutputStream.
|
static String |
formatMillis(long millis)
Format ms interval to min/sec/ms
|
static Throwable |
getAssignableCauseExceptionFromHierarchy(Exception sourceException,
Class checkCauseExceptionClass) |
static Throwable |
getCauseExceptionFromHierarchy(Exception sourceException,
Class checkCauseExceptionClass)
This method checks whole hierarchy for the exception cause.
|
static String |
getCauseExceptionMessageFromHierarchy(Exception sourceException,
Class checkCauseExceptionClass)
This method checks whole hierarchy for the exception cause.
|
static Map<String,ClusterMemberInfo> |
getClusterMembersInfoMap(ClusterPolicy clusterPolicy)
Keys in this map are cluster member names.
|
static Set<ClusterMemberInfo> |
getClusterMembersInfoSet(ClusterPolicy clusterPolicy) |
static String |
getExportCodebase(Object service)
Get the codebase for the service by getting the service's classloader and extracting only the
http: adress and port number
|
static Set<String> |
getExportCodebasesSet(Object service)
Get the codebase for the service by getting the service's classloader and extracting only the
http: adress and port number
|
static String |
getJiniGroupRepresentation(IRemoteJSpaceAdmin spaceAdmin) |
static String |
getJMXConnectionUrl(ServiceItem serviceItem)
Get the String value found in the JMXConnection entry, or null if the attribute set does not
include a JMXConnection
|
static String |
getLookupGroupsStringRepresentation(String[] lookupGroups) |
static String |
getLookupLocatorsStringRepresentation(LookupLocator[] lookupLocators) |
static Object |
getObjectFromSpaceByUid(IJSpace spaceProxy,
String uid) |
static String |
getPropertiesPresentation(Properties props) |
static Throwable |
getRootCauseException(Throwable sourceException) |
static ServiceID |
getServiceID(ReferentUuid service) |
static Entry |
getServiceItemLookupAttributeName(ServiceItem serviceItem,
Class<? extends Entry> entryClass) |
static ServiceID |
getSpaceServiceID(IJSpace space) |
static String |
getStackTrace(Throwable t)
Converts the stack trace of the specified exception to a string.
|
static String |
getTransactionLockOperationTypeName(UnderTxnLockedObject lockedObject) |
static String |
getTransactionLockTypeName(UnderTxnLockedObject lockedObject) |
static String |
getTransactionStatusName(int transactionStatus) |
static String |
getTransactionTypeName(int transactionType) |
static String |
getZonesStringRepresentation(String[] zones) |
static boolean |
isEmpty(String s)
Check if the given string is empty or null.
|
static boolean |
isEmpty(String s,
boolean isWithTrim) |
static boolean |
isJDK_1_4Runtime() |
static boolean |
isJMXRemotePortDefined(ServiceItem serviceItem) |
static boolean |
isObjectEquals(Object obj1,
Object obj2) |
static boolean |
isSameException(Throwable exception1,
Throwable exception2) |
static boolean |
isStringEquals(String s1,
String s2) |
static boolean |
isStringEqualsIgnoreCase(String s1,
String s2) |
static void |
normalize(Node node)
Normalize DOM tree.
|
static Document |
overrideClusterConfigWithXPath(Properties customProps,
Document clusterConfigRootDoc) |
static Document |
overrideClusterConfigWithXPath(String xpath,
String newValue,
Document clusterConfigRootDoc)
A method which overrides cluster configuration xml using a XPath key/value pair passed
through custom properties.
|
static boolean |
parseBooleanTag(String tag,
String s)
Parses the string argument as a boolean.
|
static boolean |
parseBooleanTag(String tag,
String s,
boolean defaultValue)
Parses the string argument as a boolean.
|
static String[] |
parseLookupGroups(String lookupGroups) |
static Properties |
parsePropertiesParam(String argsStr) |
static String |
removeDelimiter(String s,
char delim)
Removes Inverted Commas from the string.
|
static String |
removeDelimiter(String s,
char delim,
char openEscape,
char closeEscape)
Removes delimiter from the string ignores parts in the escapes.
|
static String |
removeInvertedCommas(String s)
Removes Inverted Commas from the string.
|
static String |
replaceInString(String content,
String oldStr,
String newStr,
boolean replaceAll)
Replace the desired string in all
content string. |
static String |
retrieveName(Entry[] attrs) |
static String |
retriveClusterName(Entry[] attrs) |
static String |
retriveHostAddress(NIOInfoProvider nioInfoProvider) |
static String |
retriveHostName(NIOInfoProvider nioInfoProvider) |
static void |
setXMLImplSystemProps()
Setting the XML parser and converter implementations.
|
static String[] |
splitString(String source,
char delimeter)
Returns pair of String objects ( packed in as String array ) that are deparated by one
delimeter character in passed source String object.
|
static void |
throwEngineInternalSpaceException(String msg,
Exception cause) |
static void |
throwInternalSpaceException(String msg,
Exception cause) |
static void |
throwLeaseInternalSpaceException(String msg,
Exception cause) |
static void |
throwReplicationInternalSpaceException(String msg,
Exception cause) |
public static final String BLANK_VALUE
public static final String YES_VAL
public static final String NO_VAL
public static final String SECURED_HIDDEN_VALUE
public static final String NOT_AVAILABLE_STR
public static final String LINE_SEPARATOR
public static boolean domWriter(Node node, PrintStream ps, String prefix)
domWriter
function DOM tree will look like this: value node
- XML DOM tree.ps
- OutputStream it's can be FileOutputStream, System.outprefix
- Number of space between tagstrue
if the node is a value node, false
otherwise
true
normalize(Node node)
public static String createContainerPresentName(String hostName, String containerName)
hostName
- host namecontainerName
- container namepublic static boolean parseBooleanTag(String tag, String s)
boolean
returned represents the
value true
if the string argument is not null
, is not a
sys-property, and is equal, ignoring case, to the string "true"
.tag
- the xml-tag
containing the booleans
- the String
containing the boolean representation to be parsedIllegalArgumentException
- if the string does not contain a parsable boolean.public static boolean parseBooleanTag(String tag, String s, boolean defaultValue)
boolean
returned represents the
value true
if the string argument is not null
, is not a
sys-property, and is equal, ignoring case, to the string "true"
.tag
- the xml-tag
containing the booleans
- the String
containing the boolean representation to be
parseddefaultValue
- the default value if property is not definedIllegalArgumentException
- if the string does not contain a parsable boolean.public static void normalize(Node node)
node
- Dom tree.domWriter(Node node, PrintStream ps, String prefix)
public static void convertDOMTreeFromSystemProperty(Node node)
node
- Dom tree.domWriter(Node node, PrintStream ps, String prefix)
,
normalize(Node)
public static Document convertToClusterConfiguration(Document clusterXMLDomElement, InputStream clusterXSLPolicy) throws IOException, TransformerConfigurationException, TransformerException, ParserConfigurationException, SAXException
SAXException
- in case an xsd validation fails for some reasonIOException
TransformerConfigurationException
TransformerException
ParserConfigurationException
public static Document overrideClusterConfigWithXPath(String xpath, String newValue, Document clusterConfigRootDoc) throws Exception
xpath
- a XPath string such as /cluster-config/groups/group/load-bal-policy/proxy-broadcast-threadpool-min-size
while in the custom properties we pass it using a dot e.g.:
cluster-config.groups.group.load-bal-policy.proxy-broadcast-threadpool-min-size=33Exception
- in case org.apache.xpath.XPathAPI is not found or TransformerException in
case error during transformation process.public static Document overrideClusterConfigWithXPath(Properties customProps, Document clusterConfigRootDoc) throws Exception
Exception
public static Document buildClusterXMLDom(int _totalMembers, int _backupMembers, String _clusterSchemaName, String _clusterName, String _distCacheConfigName, String _jmsConfigName, String _groups) throws ParserConfigurationException
_totalMembers
- The number of space/cache nodes/spaces in this cluster. The format
of the total_members={number of primary instances, number of backup
instances per primary} If ?total_members=4,2 the value is 4,2 means
that this cluster contains up to 4 primary instances each
containing 2 backup instances._backupMembers
- stands for the SpaceURL backups part of the ?total_numbers option,
total_members={number of primary instances, number of backup
instances per primary} In this example the value is 4,2 which means
that this cluster contains up to 4 primary instances each
containing 2 backup instances.._clusterSchemaName
- The cluster schema XSL file to be used to be build the cluster XML
Dom._clusterName
- Used also as the cache name.ParserConfigurationException
com.j_spaces.tools.xslt.XSLTConverter
,
com.j_spaces.core.cluster.ClusterXML
public static void setXMLImplSystemProps()
public static String replaceInString(String content, String oldStr, String newStr, boolean replaceAll)
content
string. This method ignoring Case
Sensitive.
For example: String content = "Hello World Hello World say Igor 1000 times"; String replStr =
replaceInString(content,"Hello", "I Love", true); Output ==> "I Love I Love say Igor 1000
times"content
- The content string where will be executing replacing.oldStr
- The string which should find in content
and replace.newStr
- The string which will be replaced with old
string.replaceAll
- true
if replace in all content
,
false
the replace will be executed only one time.public static String getStackTrace(Throwable t)
public static String getPropertiesPresentation(Properties props)
public static String getCauseExceptionMessageFromHierarchy(Exception sourceException, Class checkCauseExceptionClass)
sourceException
- hierarchy of cause exception belongs to this exception will
be checkedcheckCauseExceptionClass
- Class instancepublic static Throwable getCauseExceptionFromHierarchy(Exception sourceException, Class checkCauseExceptionClass)
sourceException
- hierarchy of cause exception belongs to this exception will
be checkedcheckCauseExceptionClass
- Class instancepublic static Throwable getAssignableCauseExceptionFromHierarchy(Exception sourceException, Class checkCauseExceptionClass)
public static boolean isEmpty(String s)
s
- String to checkpublic static boolean isEmpty(String s, boolean isWithTrim)
public static ServiceID getServiceID(ReferentUuid service)
public static String removeInvertedCommas(String s)
public static String removeDelimiter(String s, char delim)
delim
- the delimiters.public static String removeDelimiter(String s, char delim, char openEscape, char closeEscape)
delim
- the delimiters.public static String getJiniGroupRepresentation(IRemoteJSpaceAdmin spaceAdmin) throws RemoteException
RemoteException
public static Object getObjectFromSpaceByUid(IJSpace spaceProxy, String uid) throws Exception
Exception
public static void throwInternalSpaceException(String msg, Exception cause) throws InternalSpaceException
InternalSpaceException
public static void throwLeaseInternalSpaceException(String msg, Exception cause) throws InternalSpaceException
InternalSpaceException
public static void throwEngineInternalSpaceException(String msg, Exception cause) throws InternalSpaceException
InternalSpaceException
public static ProxyInternalSpaceException createProxyInternalSpaceException(Exception e) throws InternalSpaceException
InternalSpaceException
public static void throwReplicationInternalSpaceException(String msg, Exception cause) throws InternalSpaceException
InternalSpaceException
public static long countSpaceObjects(SpaceRuntimeInfo info)
public static String[] splitString(String source, char delimeter)
source
- string with only one delimeter characterdelimeter
- delimeter characterpublic static String createFullSpaceName(String containerName, String spaceName)
public static String formatMillis(long millis)
public static Map<String,ClusterMemberInfo> getClusterMembersInfoMap(ClusterPolicy clusterPolicy)
clusterPolicy
- clusterPolicy instance that represents clusterpublic static Set<ClusterMemberInfo> getClusterMembersInfoSet(ClusterPolicy clusterPolicy)
public static String retriveHostName(NIOInfoProvider nioInfoProvider) throws RemoteException
RemoteException
public static String retriveHostAddress(NIOInfoProvider nioInfoProvider) throws RemoteException
RemoteException
public static String getJMXConnectionUrl(ServiceItem serviceItem)
public static boolean isJMXRemotePortDefined(ServiceItem serviceItem)
public static boolean isJDK_1_4Runtime()
public static String createServiceName(String serviceType, int agentID, long pid, String[] zones)
public static String getLookupGroupsStringRepresentation(String[] lookupGroups)
public static String getLookupLocatorsStringRepresentation(LookupLocator[] lookupLocators)
public static Entry getServiceItemLookupAttributeName(ServiceItem serviceItem, Class<? extends Entry> entryClass)
public static String getTransactionTypeName(int transactionType)
public static String getTransactionStatusName(int transactionStatus)
public static String getTransactionLockTypeName(UnderTxnLockedObject lockedObject)
public static String getTransactionLockOperationTypeName(UnderTxnLockedObject lockedObject)
public static Properties parsePropertiesParam(String argsStr)
public static Set<String> getExportCodebasesSet(Object service)
Copyright © GigaSpaces.