code
stringlengths 73
34.1k
| label
stringclasses 1
value |
|---|---|
private int initStepTransactionTimeout() {
logger.entering(sourceClass, "initStepTransactionTimeout");
Properties p = runtimeStepExecution.getProperties();
int timeout = DEFAULT_TRAN_TIMEOUT_SECONDS; // default as per spec.
if (p != null && !p.isEmpty()) {
String propertyTimeOut = p.getProperty("javax.transaction.global.timeout");
if (logger.isLoggable(Level.FINE)) {
logger.log(Level.FINE, "javax.transaction.global.timeout = {0}", propertyTimeOut == null ? "<null>" : propertyTimeOut);
}
if (propertyTimeOut != null && !propertyTimeOut.isEmpty()) {
timeout = Integer.parseInt(propertyTimeOut, 10);
}
}
logger.exiting(sourceClass, "initStepTransactionTimeout", timeout);
return timeout;
}
|
java
|
@Trivial
private static String replaceWhitespace(String value) {
final int length = value.length();
for (int i = 0; i < length; ++i) {
char c = value.charAt(i);
if (c < 0x20 && (c == 0x9 || c == 0xA || c == 0xD)) {
return replace0(value, i, length);
}
}
return value;
}
|
java
|
private void setMessagingEngineUuid(SIBUuid8 uuid)
{
if (tc.isEntryEnabled())
SibTr.entry(tc, "setMessagingEngineUuid", new Object[] { uuid });
messagingEngineUuid = uuid;
if (tc.isEntryEnabled())
SibTr.exit(tc, "setMessagingEngineUuid");
}
|
java
|
public static Map<String, List<Map<String, Object>>> nest(Map<String, Object> map, String... keys) {
Map<String, List<Map<String, Object>>> result = new HashMap<String, List<Map<String, Object>>>(keys.length);
String keyMatch = "";
for (String key : keys) {
result.put(key, new ArrayList<Map<String, Object>>());
keyMatch = MessageFormat.format("{0}{1}|", keyMatch, Pattern.quote(key));
}
String patternString = MessageFormat.format("^({0})\\.([0-9]*)\\.(.*)", keyMatch.substring(0, keyMatch.length() - 1));
Pattern pattern = Pattern.compile(patternString);
for (Map.Entry<String, Object> entry : map.entrySet()) {
String k = entry.getKey();
Matcher matcher = pattern.matcher(k);
if (matcher.matches()) {
int base = 1;
String key = matcher.group(1);
processMatch(result.get(key), entry.getValue(), matcher, base);
}
}
return result;
}
|
java
|
private static String getUserHome() {
String home;
if (platformType == SelfExtractUtils.PlatformType_CYGWIN) {
home = System.getenv("HOME");
} else {
home = System.getProperty("user.home");
}
return home;
}
|
java
|
private static String createIfNeeded(String dir) {
File f = new File(dir);
if (f.exists()) {
return dir;
} else {
boolean success = f.mkdirs();
if (success)
return dir;
else
return null;
}
}
|
java
|
private static String jarFileName() {
// do this first so we can access extractor, ok to invoke more than once
createExtractor();
// get <name> from path/<name>.jar
String fullyQualifiedFileName = extractor.container.getName();
int lastSeparator = fullyQualifiedFileName.lastIndexOf(File.separatorChar);
String simpleFileName = fullyQualifiedFileName.substring(lastSeparator + 1);
int dotIdx = simpleFileName.lastIndexOf('.');
if (dotIdx != -1) {
return simpleFileName.substring(0, simpleFileName.lastIndexOf('.'));
}
return simpleFileName;
}
|
java
|
private static void disable2PC(String extractDirectory, String serverName) throws IOException {
String fileName = extractDirectory + File.separator + "wlp" + File.separator + "usr" + File.separator + "servers" + File.separator + serverName + File.separator
+ "jvm.options";
BufferedReader br = null;
BufferedWriter bw = null;
StringBuffer sb = new StringBuffer();
try {
String sCurrentLine;
File file = new File(fileName);
// if file doesnt exists, then create it
if (!file.exists()) {
boolean success = file.createNewFile();
if (!success) {
throw new IOException("Failed to create file " + fileName);
}
} else {
// read existing file content
br = new BufferedReader(new InputStreamReader(new FileInputStream(fileName), "UTF-8"));
while ((sCurrentLine = br.readLine()) != null) {
sb.append(sCurrentLine + "\n");
}
}
// write property to disable 2PC commit
String content = "-Dcom.ibm.tx.jta.disable2PC=true";
bw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file.getAbsoluteFile()), "UTF-8"));
bw.write(sb.toString());
bw.write(content);
} finally {
if (br != null)
br.close();
if (bw != null)
bw.close();
}
}
|
java
|
private static int runServer(String extractDirectory, String serverName, String[] args) throws IOException, InterruptedException {
int rc = 0;
Runtime rt = Runtime.getRuntime();
String action = "run";
if (System.getenv("WLP_JAR_DEBUG") != null)
action = "debug";
// unless user specifies to enable 2PC, disable it
if (System.getenv("WLP_JAR_ENABLE_2PC") == null)
disable2PC(extractDirectory, serverName);
String cmd = extractDirectory + File.separator + "wlp" + File.separator + "bin" + File.separator + "server " + action + " " + serverName;
if (args.length > 0) {
StringBuilder appArgs = new StringBuilder(" --");
for (String arg : args) {
appArgs.append(" ").append(arg);
}
cmd += appArgs.toString();
}
System.out.println(cmd);
if (platformType == SelfExtractUtils.PlatformType_UNIX) {
// cmd ready as-is for Unix
} else if (platformType == SelfExtractUtils.PlatformType_WINDOWS) {
cmd = "cmd /k " + cmd;
} else if (platformType == SelfExtractUtils.PlatformType_CYGWIN) {
cmd = "bash -c " + '"' + cmd.replace('\\', '/') + '"';
}
Process proc = rt.exec(cmd, SelfExtractUtils.runEnv(extractDirectory), null); // run server
// setup and start reader threads for error and output streams
StreamReader errorReader = new StreamReader(proc.getErrorStream(), "ERROR");
errorReader.start();
StreamReader outputReader = new StreamReader(proc.getInputStream(), "OUTPUT");
outputReader.start();
// now setup the shutdown hook
Runtime.getRuntime().addShutdownHook(new Thread(new ShutdownHook(platformType, extractDirectory, serverName, outputReader, errorReader)));
// wait on server start process to complete, capture and pass on return code
rc = proc.waitFor();
return rc;
}
|
java
|
private void isInitialized(boolean condition, String propName) {
if (condition == true) {
IllegalStateException e = new IllegalStateException("J2CGlobalConfigProperties: internal error. Set once property already set.");
Tr.error(tc, "SET_ONCE_PROP_ALREADY_SET_J2CA0159", (Object) null);
throw e;
}
}
|
java
|
public synchronized final void applyRequestGroupConfigChanges() {
// Note: on the following call the "false,true" forces the change notification
// to be sent. The listener will then pick up all property values in the
// group.
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
Tr.entry(this, tc, "applyRequestGroupConfigChanges");
changeSupport.firePropertyChange("applyRequestGroupConfigChanges", false, true);
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
Tr.exit(this, tc, "applyRequestGroupConfigChanges");
}
|
java
|
public Object get(int key) throws SIErrorException // D214655
{
if (tc.isEntryEnabled()) SibTr.entry(tc, "get");
if (tc.isDebugEnabled()) SibTr.debug(tc, "key: "+key); // f174137
captiveComparitorKey.setValue(key);
if (tc.isDebugEnabled()) SibTr.debug(tc, "captiveComparitorKey: "+captiveComparitorKey); // f174317
// Start D214655
Object retObject = map.get(captiveComparitorKey);
if (retObject == null)
{
// If no object existed this is always an error too
throw new SIErrorException(
nls.getFormattedMessage("NO_SUCH_KEY_SICO2059", new Object[] {""+key}, null) // D256974
);
}
if (tc.isEntryEnabled()) SibTr.exit(tc, "get");
return retObject;
// End D214655
}
|
java
|
public Object remove(int key) throws SIErrorException // D214655
{
if (tc.isEntryEnabled()) SibTr.entry(tc, "remove", ""+key);
captiveComparitorKey.setValue(key);
// Start D214655
Object retObject = map.remove(captiveComparitorKey);
if (retObject == null)
{
// If no object existed this is always an error too
throw new SIErrorException(
nls.getFormattedMessage("NO_SUCH_KEY_SICO2059", new Object[] {""+key}, null) // D256974
);
}
if (tc.isEntryEnabled()) SibTr.exit(tc, "remove");
return retObject;
// End D214655
}
|
java
|
public Iterator iterator()
{
if (tc.isEntryEnabled()) SibTr.entry(tc, "iterator");
if (tc.isEntryEnabled()) SibTr.exit(tc, "iterator");
return map.values().iterator();
}
|
java
|
public boolean containsKey(int id)
{
if (tc.isEntryEnabled()) SibTr.entry(tc, "get", ""+id);
captiveComparitorKey.setValue(id);
final boolean result = map.containsKey(captiveComparitorKey);
if (tc.isEntryEnabled()) SibTr.exit(tc, "get", ""+result);
return result;
}
|
java
|
public static Object checkCast(Object value, Object object, String valueClassName)
{
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
{
ClassLoader valueLoader = value == null ? null :
AccessController.doPrivileged(new GetClassLoaderPrivileged(value.getClass()));
ClassLoader contextLoader =
AccessController.doPrivileged(new GetContextClassLoaderPrivileged());
ClassLoader objectLoader =
AccessController.doPrivileged(new GetClassLoaderPrivileged(object.getClass()));
ClassLoader objectValueLoader;
try
{
Class<?> objectValueClass = Class.forName(valueClassName, false, objectLoader);
objectValueLoader = objectValueClass == null ? null :
AccessController.doPrivileged(new GetClassLoaderPrivileged(objectValueClass));
} catch (Throwable t)
{
Tr.debug(tc, "checkCast: failed to load " + valueClassName, t);
objectValueLoader = null;
}
Tr.debug(tc, "checkCast: value=" + Util.identity(value) +
", valueClassName=" + valueClassName,
", valueLoader=" + Util.identity(valueLoader) +
", contextLoader=" + Util.identity(contextLoader) +
", object=" + Util.identity(object) +
", objectLoader=" + Util.identity(objectLoader) +
", objectValueLoader=" + Util.identity(objectValueLoader));
}
return value;
}
|
java
|
GBSNode getNode(Object newKey)
{
GBSNode p;
if (_nodePool == null)
p = new GBSNode(this, newKey);
else
{
p = _nodePool;
_nodePool = p.rightChild();
p.reset(newKey);
}
return p;
}
|
java
|
public void prePopulate(int x)
{
for (int i = 0; i < x; i++)
{
GBSNode p = new GBSNode(this);
releaseNode(p);
}
}
|
java
|
public int maximumFringeImbalance()
{
int maxBal;
GBSNode q = root();
if (q.leftChild() == null)
{
maxBal = kFactor() - 1;
if (maxBal < 3)
maxBal = 3;
}
else
{
if ((kFactor() % 3) == 0)
maxBal = kFactor() + 2;
else
maxBal = kFactor() + 1;
}
return maxBal;
}
|
java
|
private int calcTZeroDepth(int proposedK)
{
int d = -1;
if ( (proposedK >= 0) && (proposedK < _t0_d.length) )
d = _t0_d[proposedK];
if (d < 0)
{
String x =
"K Factor (" + proposedK + ") is invalid.\n" +
"Valid K factors are: " + kFactorString() + ".";
throw new IllegalArgumentException(x);
}
return d;
}
|
java
|
static boolean checkForPossibleIndexChange(
int v1,
int v2,
Throwable exc,
String msg)
{
if (v1 != v2)
return pessimisticNeeded;
else
{
GBSTreeException x = new GBSTreeException(
msg + ", v1 = " + v1, exc);
throw x;
}
}
|
java
|
public Iterator iterator()
{
GBSIterator x = new GBSIterator(this);
Iterator q = (Iterator) x;
return q;
}
|
java
|
public Object searchEqual(
Object searchKey)
{
SearchComparator comp = searchComparator(SearchComparator.EQ);
Object p = find(comp, searchKey);
return p;
}
|
java
|
public Object searchGreater(
Object searchKey)
{
SearchComparator comp = searchComparator(SearchComparator.GT);
Object p = find(comp, searchKey);
return p;
}
|
java
|
public Object searchGreaterOrEqual(
Object searchKey)
{
SearchComparator comp = searchComparator(SearchComparator.GE);
Object p = find(comp, searchKey);
return p;
}
|
java
|
private SearchNode getSearchNode()
{
Object x = _searchNode.get();
SearchNode g = null;
if (x != null)
{
g = (SearchNode) x;
g.reset();
}
else
{
g = new SearchNode();
x = (Object) g;
_searchNode.set(x);
}
return g;
}
|
java
|
private boolean optimisticFind(
SearchComparator comp,
Object searchKey,
SearchNode point)
{
point.reset();
int v1 = _vno;
if (root() != null)
{
if ((v1&1) != 0)
return pessimisticNeeded;
synchronized(point)
{
}
try
{
internalFind(comp, searchKey, point);
}
catch (NullPointerException npe)
{
//No FFDC Code Needed.
_nullPointerExceptions++;
return checkForPossibleIndexChange(v1, _vno, npe, "optimisticInsert");
}
catch (OptimisticDepthException ode)
{
//No FFDC Code Needed.
_optimisticDepthExceptions++;
return checkForPossibleIndexChange(v1, _vno, ode, "optimisticInsert");
}
if (v1 != _vno)
return pessimisticNeeded;
}
_optimisticFinds++;
return optimisticWorked;
}
|
java
|
private void pessimisticFind(
SearchComparator comp,
Object searchKey,
SearchNode point)
{
point.reset();
synchronized(this)
{
internalFind(comp, searchKey, point);
_pessimisticFinds++;
}
}
|
java
|
synchronized Object iteratorFind(
DeleteStack stack,
SearchComparator comp,
Object searchKey,
SearchNode point)
{
point.reset();
GBSNode p = root();
GBSNode l = null;
GBSNode r = null;
int lx = 0;
int rx = 0;
Object ret = null;
stack.start(dummyTopNode(), "GBSTree.iteratorFind");
while (p != null)
{
int xcc = comp.compare(searchKey, p.middleKey());
if (xcc == 0)
{
point.setFound(p, p.middleIndex());
p = null;
}
else if (xcc < 0)
{
if (p.leftChild() != null)
{
stack.push(NodeStack.PROCESS_CURRENT, p, "GBSTree.iteratorFind(1)");
l = p;
lx = stack.index();
p = p.leftChild();
}
else
{
leftSearch(comp, p, r, searchKey, point);
if (point.wasFound())
{
if (point.foundNode() == r)
stack.reset(rx - 1);
}
p = null;
}
}
else // (xcc > 0)
{
if (p.rightChild() != null)
{
stack.push(NodeStack.DONE_VISITS, p, "GBSTree.iteratorFind(2)");
r = p;
rx = stack.index();
p = p.rightChild();
}
else
{
rightSearch(comp, p, l, searchKey, point);
if (point.wasFound())
{
if (point.foundNode() == l)
stack.reset(lx - 1);
}
p = null;
}
}
}
if (point.wasFound())
{
ret = point.foundNode().key(point.foundIndex());
point.setLocation(ret);
}
return ret;
}
|
java
|
private void leftSearch(
SearchComparator comp,
GBSNode p,
GBSNode r,
Object searchKey,
SearchNode point)
{
if (r == null) /* There is no upper predecessor */
{
int idx = p.searchLeft(comp, searchKey);
if ( !(idx < 0) )
point.setFound(p, idx);
}
else /* There is an upper predecessor */
{
int xcc = comp.compare(searchKey, r.rightMostKey());
if (xcc == 0) /* Target is right-most in upper pred. */
point.setFound(r, r.rightMostIndex());
else if (xcc > 0) /* Target (if it exists) is in left */
{
/* half of current node */
int idx = p.searchLeft(comp, searchKey);
if ( !(idx < 0) )
point.setFound(p, idx);
}
else /* Target (if it exists) is in right */
{
/* half of predecessor (if it exists) */
int idx = r.searchRight(comp, searchKey);
if ( !(idx < 0) )
point.setFound(r, idx);
}
}
}
|
java
|
private void rightSearch(
SearchComparator comp,
GBSNode p,
GBSNode l,
Object searchKey,
SearchNode point)
{
int xcc = comp.compare(searchKey, p.rightMostKey());
if (xcc == 0) /* Target is right-most key in current */
point.setFound(p, 0);
else if (xcc < 0) /* Target (if it exists) is in right */
{
/* half of current node */
int idx = p.searchRight(comp, searchKey);
if ( !(idx < 0) )
point.setFound(p, idx);
}
else /* Target (if it exists) is in left */
{
/* half of successor (if it exists) */
if (l != null)
{
int idx = l.searchLeft(comp, searchKey);
if ( !(idx < 0) )
point.setFound(l, idx);
}
}
}
|
java
|
private InsertStack getInsertStack()
{
Object x = _insertStack.get();
InsertStack g = null;
if (x != null)
{
g = (InsertStack) x;
g.reset();
}
else
{
g = new InsertStack(this);
x = (Object) g;
_insertStack.set(x);
}
return g;
}
|
java
|
public boolean insert(
Object new1)
{
boolean result;
InsertStack stack = getInsertStack();
if (root() == null)
pessimisticInsert(stack, new1);
else
{
boolean didit = optimisticInsert(stack, new1);
if (didit == pessimisticNeeded)
pessimisticInsert(stack, new1);
}
if (stack.isDuplicate())
result = false;
else
result = true;
return result;
}
|
java
|
private boolean optimisticInsert(
InsertStack stack,
Object new1)
{
InsertNodes point = stack.insertNodes();
int v1 = _vno;
if (root() == null)
return pessimisticNeeded;
if ((v1&1) != 0)
return pessimisticNeeded;
synchronized(stack)
{
}
try
{
findInsert(
point,
stack,
new1);
}
catch (NullPointerException npe)
{
//No FFDC Code Needed.
_nullPointerExceptions++;
return checkForPossibleIndexChange(v1, _vno, npe, "optimisticInsert");
}
catch (OptimisticDepthException ode)
{
//No FFDC Code Needed.
_optimisticDepthExceptions++;
return checkForPossibleIndexChange(v1, _vno, ode, "optimisticInsert");
}
synchronized(this)
{
if (v1 != _vno)
{
_optimisticInsertSurprises++;
return pessimisticNeeded;
}
_optimisticInserts++;
if (point.isDuplicate())
stack.markDuplicate();
else
{
_vno++;
if ((_vno&1) == 1)
{
finishInsert(point, stack, new1);
_population++;
}
synchronized(stack)
{
}
_vno++;
}
} // synchronized(this)
return optimisticWorked;
}
|
java
|
private synchronized boolean pessimisticInsert(
InsertStack stack,
Object new1)
{
_vno++;
if ((_vno&1) == 1)
{
if (root() == null)
{
addFirstNode(new1);
_population++;
}
else
{
InsertNodes point = stack.insertNodes();
findInsert(
point,
stack,
new1);
if (point.isDuplicate())
stack.markDuplicate();
else
{
finishInsert(point, stack, new1);
_population++;
}
}
}
synchronized(stack)
{
}
_vno++;
_pessimisticInserts++;
return optimisticWorked;
}
|
java
|
private void findInsert(
InsertNodes point,
InsertStack stack,
Object new1)
{
java.util.Comparator comp = insertComparator();
NodeInsertPoint ip = stack.nodeInsertPoint();
GBSNode p; /* P is used to march down the tree */
int xcc; /* Compare result */
GBSNode l_last = null; /* Node from which we last departed by */
/* turning left (logical successor) */
GBSNode r_last = null; /* Node from which we last departed by */
/* turning right (logical predecessor) */
p = root(); /* Root of tree */
/* Remember father of root */
stack.start(dummyTopNode(), "GBSTree.findInsert");
for (;;) /* Through the whole tree */
{
xcc = comp.compare(new1, p.middleKey());
if ( !(xcc > 0) ) /* New key <= node key */
{
GBSNode leftChild = p.leftChild();
if (leftChild != null) /* Have a left child */
{
l_last = p; /* Remember node from which we */
/* last moved left (successor) */
stack.balancedPush(NodeStack.PROCESS_CURRENT, p);
p = leftChild; /* Move left */
}
else /* Have no left child */
{
leftAdd( /* Add a left child */
p, /* Current node */
r_last, /* Node from which we last turned right */
new1, /* Key to add */
ip, /* NodeInsertPoint */
point); /* Returned InsertNodes */
break;
}
}
else /* New key > node key */
{
GBSNode rightChild = p.rightChild();
if (rightChild != null) /* There is a right child */
{
r_last = p; /* Remember node from which we */
/* last moved right (predecessor) */
stack.balancedPush(NodeStack.DONE_VISITS, p);
p = rightChild; /* Move right */
}
else /* There is no right child */
{
rightAdd( /* Add a right child */
p, /* Current node */
l_last, /* Node from which we last turned left */
new1, /* Key to add */
ip, /* NodeInsertPoint */
point); /* Returned InsertNodes */
break;
}
}
} // for
}
|
java
|
private void leftAdd(
GBSNode p,
GBSNode r,
Object new1,
NodeInsertPoint ip,
InsertNodes point)
{
if (r == null) /* There is no upper predecessor */
leftAddNoPredecessor(p, new1, ip, point);
else /* There is an upper predecessor */
leftAddWithPredecessor(p, r, new1, ip, point);
}
|
java
|
private void leftAddNoPredecessor(
GBSNode p,
Object new1,
NodeInsertPoint ip,
InsertNodes point)
{
p.findInsertPointInLeft(new1, ip);
point.setInsert(p, ip);
}
|
java
|
private void leftAddWithPredecessor(
GBSNode p,
GBSNode r,
Object new1,
NodeInsertPoint ip,
InsertNodes point)
{
java.util.Comparator comp = r.insertComparator();
int xcc = comp.compare(new1, r.rightMostKey());
if (xcc > 0) /* If key exists it is in left part */
{
/* of current node */
p.findInsertPointInLeft(new1, ip);
point.setInsert(p, ip);
}
else /* If key exists it is in right part */
{
/* of predecessor node */
r.findInsertPointInRight(new1, ip);
if (ip.isDuplicate()) /* Key is a duplicate */
point.setInsert(r, ip);
else /* Key is not a duplicate */
{
point.setInsertAndPosition(
p,
-1,
r,
ip.insertPoint());
point.setRight();
}
}
}
|
java
|
private void rightAdd(
GBSNode p,
GBSNode l,
Object new1,
NodeInsertPoint ip,
InsertNodes point)
{
if (l == null) /* There is no upper successor */
rightAddNoSuccessor(p, new1, ip, point);
else /* There is an upper successor */
rightAddWithSuccessor(p, l, new1, ip, point);
}
|
java
|
private void rightAddNoSuccessor(
GBSNode p,
Object new1,
NodeInsertPoint ip,
InsertNodes point)
{
if (p.lessThanHalfFull()) /* Node not even half full so the insert */
/* point now is high key of current */
point.setInsert(p, p.rightMostIndex());
else /* Keys exist beyond the median */
{
/* Must look for insert point */
p.findInsertPointInRight(new1, ip);
point.setInsert(p, ip);
}
}
|
java
|
private void rightAddWithSuccessor(
GBSNode p,
GBSNode l,
Object new1,
NodeInsertPoint ip,
InsertNodes point)
{
java.util.Comparator comp = l.insertComparator();
int xcc = comp.compare(new1, l.leftMostKey());
if (xcc < 0) /* If key exists it is in right part */
{
/* of current node */
if (p.lessThanHalfFull()) /* Node not even half full so the insert */
/* point now is high key of current */
point.setInsert(p, p.rightMostIndex());
else /* Keys exist beyond the median */
{
/* Must look for insert point */
p.findInsertPointInRight(new1, ip);
point.setInsert(p, ip);
}
}
else /* If key exists it is in left part */
{
/* of upper successor */
l.findInsertPointInLeft(new1, ip);
if (ip.isDuplicate()) /* Key is a duplicate */
point.setInsert(l, ip);
else /* Key is not a duplicate */
{
point.setInsertAndPosition(
p,
p.rightMostIndex(),
l,
ip.insertPoint());
point.setLeft();
}
}
}
|
java
|
private void finishInsert(
InsertNodes point,
InsertStack stack,
Object new1)
{
Object insertKey = new1;
if (point.positionNode() != null)
{
GBSNode p = point.positionNode();
int ix = point.positionIndex();
if (point.rightSide())
insertKey = p.insertByRightShift(ix, insertKey);
else
insertKey = p.insertByLeftShift(ix, insertKey);
}
/* If the insert point is at the right-most slot in a full node */
/* then we migrate the new key into the fringe. */
Object migrateKey = null;
if (point.insertIndex() == point.insertNode().topMostIndex())
migrateKey = insertKey;
else /* Insert within existing node */
migrateKey = /* Which may migrate a key out of it */
point.insertNode().insertByRightShift(
point.insertIndex(), insertKey);
insertFringeMigrate(stack, point.insertNode(), migrateKey);
}
|
java
|
private void insertFringeMigrate(
InsertStack stack,
GBSNode p,
Object mkey)
{
GBSNode endp = p;
int endIndex = stack.index();
/* Maximum number of right child nodes */
/* before the fringe must be rebalanced */
int maxBal = maximumFringeImbalance();
stack.setMigratingKey(mkey);
if (mkey != null) /* Have a key to migrate */
{
stack.processSubFringe(p); /* See InsertStack.processNode */
endp = stack.lastNode();
endIndex = stack.lastIndex();
}
if (stack.migrating()) /* Need a right child for migrating key */
{
_xno++;
endp.addRightLeaf(stack.migratingKey());
}
insertCheckFringeBalance(
stack,
endp,
endIndex,
maxBal);
}
|
java
|
private void insertCheckFringeBalance(
InsertStack stack,
GBSNode endp,
int endIndex,
int maxBal)
{
GBSNode fpoint = null; /* This points to the first half leaf we */
/* find that has a right child but no */
/* left child. If any rebalancing is */
/* to be done to a fringe, this will be */
/* the fringe balance point. */
int fDepth = 0; /* Fringe balance depth */
int fpidx = 0; /* Index into NodeStack where fpoint was */
/* last saved */
/* Check to see if we have filled out a final node, which may have */
/* filled out a fringe to the re-balance point. The absence of a */
/* left child means it is part of a fringe. If this is the case we */
/* walk backward through the tree looking for the top of the fringe. */
if ( (endp.isFull()) &&
(endp.leftChild() == null) )
{
fDepth = 1; /* Last node counts as one */
for (int j = endIndex; j > 0; j--)
{
GBSNode q = stack.node(j);
if (q.leftChild() != null)/* Found the top of the fringe */
break;
else /* Not yet the top of the fringe */
{
fDepth++; /* Bump fringe depth */
fpoint = q; /* Remember possible fringe balance point*/
fpidx = j; /* and its index in the stack */
}
}
if (fDepth >= maxBal)
{
_xno++;
GBSInsertFringe.singleInstance().balance(
kFactor(), stack, fpoint, fpidx, maxBal);
}
}
}
|
java
|
private DeleteStack getDeleteStack()
{
Object x = _deleteStack.get();
DeleteStack g = null;
if (x != null)
{
g = (DeleteStack) x;
g.reset();
}
else
{
g = new DeleteStack(this);
x = (Object) g;
_deleteStack.set(x);
}
return g;
}
|
java
|
private boolean optimisticDelete(
DeleteStack stack,
Object deleteKey)
{
DeleteNode point = stack.deleteNode();
int v1 = _vno;
if ((v1&1) != 0)
return pessimisticNeeded;
synchronized(stack)
{
}
try
{
findDelete(point, stack, deleteKey);
}
catch (NullPointerException npe)
{
//No FFDC Code Needed.
_nullPointerExceptions++;
return checkForPossibleIndexChange(v1, _vno, npe, "optimisticDelete");
}
catch (OptimisticDepthException ode)
{
//No FFDC Code Needed.
_optimisticDepthExceptions++;
return checkForPossibleIndexChange(v1, _vno, ode, "optimisticDelete");
}
synchronized(this)
{
if (v1 != _vno)
{
_optimisticDeleteSurprises++;
return pessimisticNeeded;
}
_optimisticDeletes++;
if (point.wasFound())
{
_vno++;
if ((_vno&1) == 1)
{
finishDelete(point, stack, deleteKey);
if (_population <= 0)
throw new GBSTreeException("_population = " + _population);
_population--;
}
synchronized(stack)
{
}
_vno++;
}
}
return optimisticWorked;
}
|
java
|
void iteratorSpecialDelete(
Iterator iter,
GBSNode node,
int index)
{
_vno++;
if ((_vno&1) == 1)
{
node.deleteByLeftShift(index);
node.adjustMedian();
_population--;
}
synchronized(iter)
{
}
_vno++;
}
|
java
|
private void finishDelete(
DeleteNode point,
DeleteStack stack,
Object deleteKey)
{
adjustTarget(point);
point.deleteNode().deleteByLeftShift(point.deleteIndex());
deleteFringeMigrate(stack, point.deleteNode());
}
|
java
|
private void findDelete(
DeleteNode point,
DeleteStack stack,
Object deleteKey)
{
java.util.Comparator comp = deleteComparator();
GBSNode p; /* P is used to march down the tree */
int xcc; /* Compare result */
GBSNode l_last = null; /* Node from which we last departed by */
/* turning left (logical successor) */
GBSNode r_last = null; /* Node from which we last departed by */
/* turning right (logical predecessor) */
p = root(); /* Root of tree */
/* Remember father of root */
stack.start(dummyTopNode(), "GBSTree.findDelete");
while (p != null)
{
xcc = comp.compare(deleteKey, p.middleKey());
if (xcc == 0) /* Delete key = median key */
{
midDelete(stack, p, point);
p = null;
}
else if (xcc < 0) /* Delete key < median key */
{
if (p.leftChild() != null)
{
l_last = p; /* Remember node from which we */
/* last moved left (successor) */
stack.push(NodeStack.PROCESS_CURRENT, p, "GBSTree.findDelete(1)");
p = p.leftChild();
}
else /* There is no left child */
{
/* Delete on left side */
leftDelete(p, r_last, deleteKey, point);
p = null;
}
}
else /* Delete key > median key */
{
if (p.rightChild() != null)
{
r_last = p; /* Remember node from which we */
/* last moved right (predecessor) */
stack.push(NodeStack.DONE_VISITS, p, "GBSTree.findDelete(2)");
p = p.rightChild();
}
else /* There is no right child */
{
rightDelete(p, l_last, deleteKey, point);
p = null;
}
}
}
}
|
java
|
private void midDelete(
DeleteStack stack,
GBSNode p,
DeleteNode point)
{
/* Assume no lower predecessor/successor */
point.setDelete(p, p.middleIndex());
GBSNode q = p.lowerPredecessor(stack);
if (q != null) /* Have a lower predecessor */
{
/* Elevate right-most of lower pred. */
point.setDelete(q, q.rightMostIndex());
point.setTarget(p, p.middleIndex(), DeleteNode.ADD_LEFT);
}
else /* There is no lower predecessor */
{
/* Check for lower successor */
q = p.lowerSuccessor(stack);
if (q != null) /* Have a lower successor */
{
/* Elevate left-most of lower successor */
point.setDelete(q, 0);
point.setTarget(p, p.middleIndex(), DeleteNode.ADD_RIGHT);
}
}
}
|
java
|
private void leftDelete(
GBSNode p,
GBSNode r,
Object deleteKey,
DeleteNode point)
{
if (r == null) /* There is no upper predecessor */
leftDeleteNoPredecessor(p, deleteKey, point);
else /* There is an upper predecessor */
leftDeleteWithPredecessor(p, r, deleteKey, point);
}
|
java
|
private void leftDeleteNoPredecessor(
GBSNode p,
Object deleteKey,
DeleteNode point)
{
int idx = p.findDeleteInLeft(deleteKey);
if (idx >= 0)
point.setDelete(p, idx);
}
|
java
|
private void leftDeleteWithPredecessor(
GBSNode p,
GBSNode r,
Object deleteKey,
DeleteNode point)
{
java.util.Comparator comp = p.deleteComparator();
int xcc = comp.compare(deleteKey, r.rightMostKey());
if (xcc == 0) /* Target key IS predecessor high key */
{
/* Migrate up low key of current (delete key)
into high key of predecessor (target key) */
point.setDelete(p, 0);
point.setTarget(r, r.rightMostIndex(), DeleteNode.OVERLAY_RIGHT);
}
else if (xcc > 0) /* Target key > predecessor high key */
{
/* Target is in left part of current */
int ix = p.findDeleteInLeft(deleteKey);
if ( !(ix < 0) )
point.setDelete(p, ix);
}
else /* Target key < predecessor high */
{
/* It is in right half of predecessor */
int ix = r.findDeleteInRight(deleteKey);
if ( !(ix < 0) )
{
point.setTarget(r, ix, DeleteNode.ADD_RIGHT);
point.setDelete(p, 0);
}
}
}
|
java
|
private void rightDelete(
GBSNode p,
GBSNode l,
Object deleteKey,
DeleteNode point)
{
if (l == null) /* There is no upper successor */
rightDeleteNoSuccessor(p, deleteKey, point);
else /* There is an upper successor */
rightDeleteWithSuccessor(p, l, deleteKey, point);
}
|
java
|
private void rightDeleteNoSuccessor(
GBSNode p,
Object deleteKey,
DeleteNode point)
{
int idx = p.findDeleteInRight(deleteKey);
if (idx >= 0)
point.setDelete(p, idx);
}
|
java
|
private void rightDeleteWithSuccessor(
GBSNode p,
GBSNode l,
Object deleteKey,
DeleteNode point)
{
java.util.Comparator comp = p.deleteComparator();
int xcc = comp.compare(deleteKey, l.leftMostKey());
if (xcc == 0) /* Target key IS low key of successor */
{
/* Migrate up high key of current (delete key)
into low key of successor (target key) */
point.setDelete(p, p.rightMostIndex());
point.setTarget(l, 0, DeleteNode.OVERLAY_LEFT);
}
else if (xcc < 0) /* Less than left most key of successor */
{
/* Target is in right of current */
int ix = p.findDeleteInRight(deleteKey);
if (ix >= 0)
point.setDelete(p, ix);
}
else /* Greater than left most of successor */
{
/* Target is in left of successor */
int ix = l.findDeleteInLeft(deleteKey);
if (ix >= 0)
{
/* Migrate up high key of current (delete key) into
low key of successor (hole left after keys moved) */
point.setDelete(p, p.rightMostIndex());
point.setTarget(l, ix, DeleteNode.ADD_LEFT);
}
}
}
|
java
|
private void deleteFringeMigrate(
DeleteStack stack,
GBSNode p)
{
GBSNode endp = p; /* Last node processed */
int endIndex = stack.index(); /* Index to last parent */
stack.add(0, p); /* Put last node in stack for possible */
/* use by rebalance */
/* Maximum number of right child nodes */
/* before the fringe must be rebalanced */
int maxBal = maximumFringeImbalance();
stack.processSubFringe(p); /* See DeleteStack.processNode */
endp = stack.lastNode();
endIndex = stack.lastIndex();
deleteCheckFringeBalance(
stack,
endp,
endIndex,
maxBal);
}
|
java
|
private void deleteCheckFringeBalance(
DeleteStack stack,
GBSNode endp,
int endIndex,
int maxBal)
{
int fDepth = 0; /* Fringe balance depth */
fDepth = 0;
if (endp.leftChild() == null)
{
fDepth = 1; /* Last node counts as one */
for (int j = endIndex; j > 0; j--)
{
GBSNode q = stack.node(j);
if (q.leftChild() == null)/* Have not found end yet */
fDepth++;
else /* Found the top of the fringe */
break;
}
}
int t0_depth = tZeroDepth();
int t = t0_depth;
if (t < 1)
t = 1;
if ( (stack.maxDepth() >= t) &&/* Deep enough for a t0 and */
(endp.population() == (endp.width()-1)) )/* Last node was full */
{
/* Check for a possible t0 tree */
int j = 1;
if ((kFactor() % 3) == 0)
j = 2;
if (fDepth == j)
{
_xno++;
GBSDeleteFringe.singleInstance().balance(
tZeroDepth(), stack);
}
}
else /* Not a t0 fringe */
{
/* Check for empty node */
if (endp.population() != 0)
endp.adjustMedian();
else
{
_xno++;
GBSNode p = stack.node(endIndex);
if (p.leftChild() == endp)
p.setLeftChild(null);
else
p.setRightChild(null);
}
}
}
|
java
|
public static ThreadContextDescriptor deserialize(byte[] bytes, Map<String, String> execProps) throws ClassNotFoundException, IOException {
return new ThreadContextDescriptorImpl(execProps, bytes);
}
|
java
|
public static File[] listFiles(final File target, final List<Pattern> patterns, final boolean include) {
if (patterns == null || patterns.isEmpty())
return target.listFiles();
return target.listFiles(new FilenameFilter() {
@Override
public boolean accept(File dir, String name) {
for (Pattern pattern : patterns) {
Matcher matcher = pattern.matcher(name);
if (matcher.matches())
return include;
}
return !include;
}
});
}
|
java
|
public static void copyFile(File dest, File source) throws IOException {
InputStream input = null;
try {
input = new FileInputStream(source);
createFile(dest, input);
} finally {
Utils.tryToClose(input);
}
}
|
java
|
public static void createFile(final File dest, final InputStream sourceInput) throws IOException {
if (sourceInput == null || dest == null)
return;
FileOutputStream fos = null;
try {
if (!dest.getParentFile().exists()) {
if (!dest.getParentFile().mkdirs()) {
throw new FileNotFoundException();
}
}
fos = TextFileOutputStreamFactory.createOutputStream(dest);
byte[] buffer = new byte[DEFAULT_BUFFER_SIZE];
int count = -1;
while ((count = sourceInput.read(buffer)) > 0) {
fos.write(buffer, 0, count);
}
fos.flush();
} finally {
Utils.tryToClose(fos);
Utils.tryToClose(sourceInput);
}
}
|
java
|
public static void copyDir(File from, File to) throws FileNotFoundException, IOException {
File[] files = from.listFiles();
if (files != null) {
for (File ff : files) {
File tf = new File(to, ff.getName());
if (ff.isDirectory()) {
if (tf.mkdir()) {
copyDir(ff, tf);
}
} else if (ff.isFile()) {
copyFile(tf, ff);
}
}
}
}
|
java
|
public static boolean isUnderDirectory(File child, File parent) {
if (child == null || parent == null)
return false;
URI childUri = child.toURI();
URI relativeUri = parent.toURI().relativize(childUri);
return relativeUri.equals(childUri) ? false : true;
}
|
java
|
public static String normalizeEntryPath(String entryPath) {
if (entryPath == null || entryPath.isEmpty())
return "";
entryPath = entryPath.replace("\\", "/");
if (entryPath.startsWith("/")) {
if (entryPath.length() == 1) {
entryPath = "";
} else {
entryPath = entryPath.substring(1, entryPath.length());
}
}
return entryPath;
}
|
java
|
public static String normalizeDirPath(String dirPath) {
if (dirPath == null || dirPath.isEmpty())
return "";
dirPath = dirPath.replace("\\", "/");
if (!dirPath.endsWith("/")) {
dirPath = dirPath + "/";
}
return dirPath;
}
|
java
|
private static final boolean contains(Collection<String> list, String value) {
for (String item : list)
if (item.contains(value))
return true;
return false;
}
|
java
|
static String getConnectionPoolDataSourceClassName(String vendorPropertiesPID) {
String[] classNames = classNamesByPID.get(vendorPropertiesPID);
return classNames == null ? null : classNames[1];
}
|
java
|
static String getDataSourceClassName(Collection<String> fileNames) {
for (Map.Entry<String, String[]> entry : classNamesByKey.entrySet())
if (contains(fileNames, entry.getKey())) {
String[] classNames = entry.getValue();
return classNames == null ? null : classNames[0];
}
return null;
}
|
java
|
static String getDataSourceClassName(String vendorPropertiesPID) {
String[] classNames = classNamesByPID.get(vendorPropertiesPID);
return classNames == null ? null : classNames[0];
}
|
java
|
static String getXADataSourceClassName(String vendorPropertiesPID) {
String[] classNames = classNamesByPID.get(vendorPropertiesPID);
return classNames == null ? null : classNames[2];
}
|
java
|
private static String tryToLoad(Class<?> type, ClassLoader loader, String... classNames) {
final boolean trace = TraceComponent.isAnyTracingEnabled();
for (String className : classNames)
try {
Class<?> c = loader.loadClass(className);
boolean isInstance = type.isAssignableFrom(c);
if (trace && tc.isDebugEnabled())
Tr.debug(tc, className + " is " + (isInstance ? "" : "not ") + "an instance of " + type.getName());
if (type.isAssignableFrom(c))
return className;
} catch (ClassNotFoundException x) {
if (trace && tc.isDebugEnabled())
Tr.debug(tc, className + " not found on " + loader);
}
return null;
}
|
java
|
protected final String[] getAttributes(String key) {
ArrayList<String> array = this._attributes.get(key);
if (array != null && array.size() > 0) {
String[] type = new String[array.size()];
return array.toArray(type);
}
return null;
}
|
java
|
public Object handleOperation(String operation, Object[] params) throws IOException {
if (OPERATION_DOWNLOAD.equals(operation)) {
if (params.length == 2) {
downloadFile((String) params[0], (String) params[1]);
} else {
//partial download
return downloadFile((String) params[0], (String) params[1], (Long) params[2], (Long) params[3]);
}
} else if (OPERATION_UPLOAD.equals(operation)) {
uploadFile((String) params[0], (String) params[1], (Boolean) params[2]);
} else if (OPERATION_DELETE.equals(operation)) {
deleteFile((String) params[0]);
} else if (OPERATION_DELETE_ALL.equals(operation)) {
deleteAll((List<String>) params[0]);
} else {
throw logUnsupportedOperationError("handleOperation", operation);
}
//currently all operations are void, so return null.
return null;
}
|
java
|
@Override
public long read(long numBytes, int timeout) throws IOException {
long readCount = 0;
H2StreamProcessor p = muxLink.getStreamProcessor(streamID);
try {
p.getReadLatch().await(timeout, TimeUnit.MILLISECONDS);
readCount = p.readCount(numBytes, this.getBuffers());
} catch (InterruptedException e) {
throw new IOException("read was stopped by an InterruptedException: " + e);
}
return readCount;
}
|
java
|
@FFDCIgnore(PrivilegedActionException.class)
private String getConfigNameForRef(final String ref) {
String name = null;
if (ref != null) {
final ConfigurationAdmin configAdmin = configAdminRef.getService();
Configuration config;
try {
config = AccessController.doPrivileged(new PrivilegedExceptionAction<Configuration>() {
@Override
public Configuration run() throws IOException {
return configAdmin.getConfiguration(ref, configAdminRef.getReference().getBundle().getLocation());
}
});
} catch (PrivilegedActionException paex) {
return null;
}
Dictionary<String, Object> props = config.getProperties();
name = (String) props.get(KEY_NAME);
}
return name;
}
|
java
|
public static synchronized void addConfig(String id, String uri, Map<String, String> params) {
uriMap.put(id, uri);
configInfo.put(uri, params);
resolvedConfigInfo.clear();
if (uri.endsWith("*")) {
wildcardsPresentInConfigInfo = true;
}
}
|
java
|
public String generateSessionId()
{
byte random[] = new byte[16];
// Render the result as a String of hexadecimal digits
StringBuilder buffer = new StringBuilder();
int resultLenBytes = 0;
while (resultLenBytes < sessionIdLength)
{
getRandomBytes(random);
for (int j = 0;
j < random.length && resultLenBytes < sessionIdLength;
j++)
{
byte b1 = (byte) ((random[j] & 0xf0) >> 4);
byte b2 = (byte) (random[j] & 0x0f);
if (b1 < 10)
{
buffer.append((char) ('0' + b1));
}
else
{
buffer.append((char) ('A' + (b1 - 10)));
}
if (b2 < 10)
{
buffer.append((char) ('0' + b2));
}
else
{
buffer.append((char) ('A' + (b2 - 10)));
}
resultLenBytes++;
}
}
if (jvmRoute != null && jvmRoute.length() > 0)
{
buffer.append('.').append(jvmRoute);
}
return buffer.toString();
}
|
java
|
public boolean containsKey(Object key) {
FastHashtableEntry tab[] = table;
int hash = key.hashCode();
int index = (hash & 0x7FFFFFFF) % tab.length;
for (FastHashtableEntry e = tab[index] ; e != null ; e = e.next) {
if ((e.hash == hash) && e.key.equals(key)) {
return true;
}
}
return false;
}
|
java
|
private boolean ableToFilter() {
if (filter == null)
return false;
for (int i = table.length; i-- > 0 ;) {
FastHashtableEntry newContents = null, next = null;
for (FastHashtableEntry e = table[i] ; e != null ; e = next) {
next = e.next;
if (filter.shouldRetain(e.key, e.value)) {
e.next = newContents;
newContents = e;
}
else
count--;
}
table[i] = newContents;
}
return count < threshold;
}
|
java
|
private void readObject(java.io.ObjectInputStream s)
throws IOException, ClassNotFoundException
{
// Read in the length, threshold, and loadfactor
s.defaultReadObject();
// Read the original length of the array and number of elements
int origlength = s.readInt();
int elements = s.readInt();
// Compute new size with a bit of room 5% to grow but
// No larger than the original size. Make the length
// odd if it's large enough, this helps distribute the entries.
// Guard against the length ending up zero, that's not valid.
int length = (int)(elements * loadFactor) + (elements / 20) + 3;
if (length > elements && (length & 1) == 0)
length--;
if (origlength > 0 && length > origlength)
length = origlength;
table = new FastHashtableEntry[length];
count = 0;
// Read the number of elements and then all the key/value objects
for (; elements > 0; elements--) {
Object key = s.readObject();
Object value = s.readObject();
put(key, value);
}
}
|
java
|
public boolean getBooleanProperty(String propertyName) {
boolean booleanValue = false;
// Pull the key from the property map
Object objectValue = this.properties.get(propertyName);
if (objectValue != null) {
if (objectValue instanceof Boolean) {
booleanValue = ((Boolean) objectValue).booleanValue();
} else if (objectValue instanceof String) {
booleanValue = Boolean.parseBoolean((String) objectValue);
}
}
return booleanValue;
}
|
java
|
public String getStringProperty(String propertyName) {
Object value = this.properties.get(propertyName);
if (null != value && value instanceof String) {
return (String) value;
}
return null;
}
|
java
|
private boolean getBooleanProperty(String key, String defaultValue, StringBuilder errors) {
boolean booleanValue = false;
String stringValue = null;
boolean valueCorrect = false;
// Pull the key from the property map
Object objectValue = this.properties.get(key);
if (objectValue != null) {
if (objectValue instanceof Boolean) {
booleanValue = ((Boolean) objectValue).booleanValue();
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
Tr.debug(tc, "Property " + key + " set to " + booleanValue);
}
return booleanValue;
} else if (objectValue instanceof String) {
stringValue = (String) objectValue;
}
} else {
// Key is not in map.
if (defaultValue != null) {
stringValue = defaultValue;
} else {
// No default provided. Error.
errors.append(key);
errors.append(':');
errors.append(stringValue);
errors.append('\n');
return false;
}
}
// If we get this far, we have a non null string value to work with. May be the default.
// Verify the value.
if (stringValue != null) {
if (stringValue.equals("true")) {
booleanValue = true;
valueCorrect = true;
} else if (stringValue.equals("false")) {
booleanValue = false;
valueCorrect = true;
}
}
if (valueCorrect) {
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
Tr.debug(tc, "Property " + key + " set to " + booleanValue);
}
} else {
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
Tr.debug(tc, "Property " + key + " has invalid value " + stringValue);
}
errors.append(key);
errors.append(':');
errors.append(stringValue);
errors.append('\n');
}
return booleanValue;
}
|
java
|
private int getIntProperty(String key, boolean defaultProvided, int defaultValue, StringBuilder errors) {
String value = getStringProperty(key);
if (null != value) {
try {
int realValue = Integer.parseInt(value);
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
Tr.debug(tc, "Property " + key + " set to " + realValue);
}
return realValue;
} catch (NumberFormatException nfe) {
// no FFDC required;
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
Tr.debug(tc, "Property " + key + ", format error in [" + value + "]");
}
}
}
if (!defaultProvided) {
// No default available. This is an error.
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
Tr.debug(tc, "Property " + key + " not found. Error being tallied.");
}
errors.append(key);
errors.append(":null \n");
return -1;
}
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
Tr.debug(tc, "Property " + key + " using default " + defaultValue);
}
return defaultValue;
}
|
java
|
public synchronized void lockExclusive()
{
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(this, tc, "lockExclusive", this);
boolean interrupted = false;
// If another thread is attempting to lock exclusive,
// wait for it to finish first.
while (!tryLockExclusive())
{
try
{
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) SibTr.debug(this, tc, "Waiting to get exclusive lock");
wait(1000);
}
catch (InterruptedException e)
{
// No FFDC code needed
interrupted = true;
}
}
// Wait for existing locks to be released
while (iLockCount > 0)
{
try
{
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) SibTr.debug(this, tc, "Waiting for lock count to reach 0 " + iLockCount);
wait(1000);
}
catch (InterruptedException e)
{
// No FFDC code needed
interrupted = true;
}
}
if (interrupted)
{
Thread.currentThread().interrupt();
}
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(this, tc, "lockExclusive");
}
|
java
|
public int getLocalBusinessInterfaceIndex(String interfaceName) {
if (ivBusinessLocalInterfaceClasses != null) {
for (int i = 0; i < ivBusinessLocalInterfaceClasses.length; i++) {
String bInterfaceName = ivBusinessLocalInterfaceClasses[i].getName();
if (bInterfaceName.equals(interfaceName)) {
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
Tr.debug(tc, "getLocalBusinessInterfaceIndex : " +
bInterfaceName + " at index " + i);
return i;
}
}
}
return -1;
}
|
java
|
public int getRequiredLocalBusinessInterfaceIndex(String interfaceName) throws IllegalStateException {
int interfaceIndex = getLocalBusinessInterfaceIndex(interfaceName);
if (interfaceIndex == -1) {
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
Tr.debug(tc, "getRequiredLocalBusinessInterfaceIndex : IllegalStateException : " +
"Requested business interface not found : " +
interfaceName);
throw new IllegalStateException("Requested business interface not found : " + interfaceName);
}
return interfaceIndex;
}
|
java
|
public int getRemoteBusinessInterfaceIndex(String interfaceName) {
if (ivBusinessRemoteInterfaceClasses != null) {
for (int i = 0; i < ivBusinessRemoteInterfaceClasses.length; i++) {
String bInterface = ivBusinessRemoteInterfaceClasses[i].getName();
if (bInterface.equals(interfaceName)) {
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
Tr.debug(tc, "getRemoteBusinessInterfaceIndex : " +
bInterface + " at index " + i);
return i;
}
}
}
return -1;
}
|
java
|
public int getRequiredRemoteBusinessInterfaceIndex(String interfaceName) throws IllegalStateException {
int interfaceIndex = getRemoteBusinessInterfaceIndex(interfaceName);
if (interfaceIndex == -1) {
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
Tr.debug(tc, "getRequiredRemoteBusinessInterfaceIndex : IllegalStateException : " +
"Requested business interface not found : " +
interfaceName);
throw new IllegalStateException("Requested business interface not found : " + interfaceName);
}
return interfaceIndex;
}
|
java
|
public String[][] getMethodLevelCustomFinderMethodSignatures(String cfprocessstring) {
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
Tr.entry(tc, "getMethodLevelCustomFinderMethodSignatures:" + cfprocessstring);
StringTokenizer st = new StringTokenizer(cfprocessstring, ":");
// array form [item#][CFMethodName]=methodname, e.g. findByCustomerName
// array form [item#][CFMethodParms]]=parameter list, e.g. int,java.lang.String
String cfMethodSignatureArray[][] = new String[st.countTokens()][2];
int methodCounter = 0;
while (st.hasMoreTokens()) {
String methodSignature = st.nextToken();
StringTokenizer methodSignaturest = new StringTokenizer(methodSignature, "()");
// format exepected, first attribute method name (can't be nul)
// second are the signatures parms, in order
try {
cfMethodSignatureArray[methodCounter][CF_METHOD_NAME_OFFSET] = methodSignaturest.nextToken();
if (methodSignature.equals("()")) {
cfMethodSignatureArray[methodCounter][CF_METHOD_SIG_OFFSET] = null; // no signature given, but followed expected format
} else {
cfMethodSignatureArray[methodCounter][CF_METHOD_SIG_OFFSET] = methodSignaturest.nextToken();
}
} catch (java.util.NoSuchElementException ex) {
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()
&& methodSignature != null)
Tr.debug(tc, "Processing offset [" + methodCounter + "] " + methodSignature + " failed, incorrect format");
// badSignatureGiven=true;
}
methodCounter++;
} // while
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
Tr.exit(tc, "getMethodLevelCustomFinderMethodSignatures: " + cfMethodSignatureArray);
return cfMethodSignatureArray;
}
|
java
|
public JsMessage transcribeToJmf() throws MessageCopyFailedException
, IncorrectMessageTypeException
, UnsupportedEncodingException {
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(this, tc, "transcribeToJmf");
JsMsgObject newJmo = null;
// Try/catch block in case we get an MFPUnsupportedEncodingRuntimeException because the
// payload is in an unsupported codepage. d252277.2
try {
if (this instanceof JsJmsMessageImpl) {
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) SibTr.debug(this, tc, "Transcribing from JsJmsMessageImpl");
newJmo = jmo.transcribeToJmf();
}
else {
// Non-JMS messages are not supported - they should have been converted into JMS by now
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) SibTr.debug(this, tc, "Non-JMS Messages are not yet supported");
String exString = nls.getFormattedMessage("UNEXPECTED_MESSAGE_TYPE_CWSIF0102"
,new Object[] {getJsMessageType(), MessageType.JMS}
,"The Message can not be represented as a pure JMF Message");
throw new IncorrectMessageTypeException(exString);
}
}
catch (MFPUnsupportedEncodingRuntimeException e) {
FFDCFilter.processException(e, "com.ibm.ws.sib.mfp.impl.JsMessageImpl.transcribeToJmf", "721");
// Throw the original UnsupportedEncodingException
throw (UnsupportedEncodingException)e.getCause();
}
JsMessage newMsg;
// if we have a new jmo, create a new message from it
if (newJmo != this.jmo) {
newMsg = createNewGeneralized(newJmo);
}
// otherwise, just return ourself
else {
newMsg = this;
}
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(this, tc, "transcribeToJmf", newMsg);
return newMsg;
}
|
java
|
public int getApproximateLength() {
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(this, tc, "getApproximateLength");
if (approxLength == -1) approxLength = guessApproxLength();
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(this, tc, "getApproximateLength", Integer.valueOf(approxLength));
return approxLength;
}
|
java
|
private final JsMessageImpl createNew() throws MessageCopyFailedException {
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(this, tc, "createNew");
JsMessageImpl newMsg = null;
Class msgClass = this.getClass();
try {
/* Create the new JsMessage*/
newMsg = (JsMessageImpl)msgClass.newInstance();
/* copy transients before copying JMO to ensure safe ordering - see SIB0121.mfp.2 */
copyTransients(newMsg);
/* Get a new copy of the JMO and set it into the new message*/
JsMsgObject newJmo = jmo.getCopy();
newMsg.setJmo(newJmo);
}
catch (IllegalAccessException e1) {
FFDCFilter.processException(e1, "com.ibm.ws.sib.mfp.impl.JsMessageImpl.createNew", "jsm1600");
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) SibTr.debug(this, tc, "IllegalAccessException " + e1.getMessage() + " instantiating class " + msgClass.getName());
throw new MessageCopyFailedException(e1);
}
catch (InstantiationException e2) {
FFDCFilter.processException(e2, "com.ibm.ws.sib.mfp.impl.JsMessageImpl.createNew", "jsm1610");
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) SibTr.debug(this, tc, "InstantiationException " + e2.getMessage() + " instantiating class " + msgClass.getName());
throw new MessageCopyFailedException(e2);
}
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(this, tc, "createNew", newMsg);
return newMsg;
}
|
java
|
private final JsMessageImpl createNewGeneralized(JsMsgObject newJmo) {
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(this, tc, "createNewGeneralized");
JsMessageImpl newMsg = null;
/* Now create the new JsMessage */
newMsg = new JsMessageImpl(newJmo);
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(this, tc, "createNewGeneralized", newMsg);
return newMsg;
}
|
java
|
@SuppressWarnings("rawtypes")
public static Hashtable parsePostData(ServletInputStream in, String encoding, boolean multireadPropertyEnabled) /* 157338 add throws */ throws IOException
{
int inputLen;
byte[] postedBytes = null;
String postedBody;
if (com.ibm.ejs.ras.TraceComponent.isAnyTracingEnabled()&&logger.isLoggable (Level.FINE))
logger.logp(Level.FINE, CLASS_NAME,"parsePostData","parsing chunked post data. encoding = " + encoding);
if (in == null)
throw new IllegalArgumentException("post data inputstream is null");
try
{
//
// Make sure we read the entire POSTed body.
//
ByteArrayOutputStream byteOS = new ByteArrayOutputStream(DEFAULT_BUFFER_SIZE);
do
{
byte [] readInBytes = new byte[DEFAULT_BUFFER_SIZE];
inputLen = in.read(readInBytes, 0, DEFAULT_BUFFER_SIZE);
if (inputLen > 0){
byteOS.write(readInBytes,0,inputLen);
}
}
while (inputLen != -1);
// MultiRead Start
if (multireadPropertyEnabled) {
in.close();
}
// MultiRead End
postedBytes = byteOS.toByteArray();
if (com.ibm.ejs.ras.TraceComponent.isAnyTracingEnabled()&&logger.isLoggable (Level.FINE))
logger.logp(Level.FINE, CLASS_NAME,"parsePostData","finished reading ["+postedBytes.length+"] bytes");
}
catch (IOException e)
{
com.ibm.wsspi.webcontainer.util.FFDCWrapper.processException(e, "com.ibm.ws.webcontainer.servlet.RequestUtils.parsePostData", "598");
// begin 157338
throw e;
//return new Hashtable();
// begin 157338
}
// XXX we shouldn't assume that the only kind of POST body
// is FORM data encoded using ASCII or ISO Latin/1 ... or
// that the body should always be treated as FORM data.
//
try
{
postedBody = new String(postedBytes, encoding);
}
catch (UnsupportedEncodingException e)
{
com.ibm.wsspi.webcontainer.util.FFDCWrapper.processException(e, "com.ibm.ws.webcontainer.servlet.RequestUtils.parsePostData", "618");
postedBody = new String(postedBytes);
}
if (WCCustomProperties.PARSE_UTF8_POST_DATA && encoding.equalsIgnoreCase("UTF-8")) {
for (byte nextByte : postedBytes) {
if (nextByte < (byte)0 ) {
encoding = "8859_1";
if (com.ibm.ejs.ras.TraceComponent.isAnyTracingEnabled()&&logger.isLoggable (Level.FINE))
logger.logp(Level.FINE, CLASS_NAME,"parsePostData","UTF8 post data, set encoing to 8859_1 to prevent futrther encoding");
break;
}
}
}
return parseQueryString(postedBody, encoding);
}
|
java
|
public final Item findOldestItem() throws MessageStoreException
{
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
SibTr.entry(this, tc, "findOldestItem");
ItemCollection ic = ((ItemCollection) _getMembership());
if (null == ic)
{
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
SibTr.exit(this, tc, "findOldestItem");
throw new NotInMessageStore();
}
Item item = null;
if (ic != null)
{
item = (Item) ic.findOldestItem();
}
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
SibTr.exit(this, tc, "findOldestItem", item);
return item;
}
|
java
|
protected void abort() {
if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled()) {
Tr.event(tc, "Aborting connection");
}
this.aborted = true;
}
|
java
|
protected void setTimeoutTime(int time) {
int timeout = time;
if (timeout == TCPRequestContext.NO_TIMEOUT) {
this.timeoutTime = TCPRequestContext.NO_TIMEOUT;
this.timeoutInterval = 0;
} else {
if (timeout == TCPRequestContext.USE_CHANNEL_TIMEOUT) {
timeout = getConfig().getInactivityTimeout();
}
if (timeout != ValidateUtils.INACTIVITY_TIMEOUT_NO_TIMEOUT) {
this.timeoutTime = System.currentTimeMillis() + timeout;
this.timeoutInterval = timeout;
} else {
this.timeoutTime = TCPRequestContext.NO_TIMEOUT;
this.timeoutInterval = 0;
}
}
}
|
java
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.