code
stringlengths 73
34.1k
| label
stringclasses 1
value |
|---|---|
static Selector convertRange(Selector expr, Selector bound1, Selector bound2) {
return new OperatorImpl(Operator.AND,
new OperatorImpl(Operator.GE, (Selector) expr.clone(), bound1),
new OperatorImpl(Operator.LE, (Selector) expr.clone(), bound2));
}
|
java
|
static Selector convertLike(Selector arg, String pattern, String escape) {
try
{
pattern = reduceStringLiteralToken(pattern);
boolean escaped = false;
char esc = 0;
if (escape != null) {
escape = reduceStringLiteralToken(escape);
if (escape.length() != 1)
return null;
escaped = true;
esc = escape.charAt(0);
}
return Matching.getInstance().createLikeOperator(arg, pattern, escaped, esc);
}
catch (Exception e)
{
// No FFDC Code Needed.
// FFDC driven by wrapper class.
FFDC.processException(cclass,
"com.ibm.ws.sib.matchspace.selector.impl.ParseUtil.convertLike",
e,
"1:183:1.19");
// This should never occur as to get into this we should be missing
// the sib.matchspace jar file, but we are already in it.
throw new RuntimeException(e);
}
}
|
java
|
@Override
public SecurityMetadata getSecurityMetadata() {
SecurityMetadata sm = super.getSecurityMetadata();
if (sm == null) {
return getDefaultAdminSecurityMetadata();
} else {
return sm;
}
}
|
java
|
private void buildPolicyErrorMessage(String msgKey, String defaultMessage, Object... arg1) {
/* The message need to be logged only for level below 'Warning' */
if (TraceComponent.isAnyTracingEnabled() && tc.isWarningEnabled()) {
String messageFromBundle = Tr.formatMessage(tc, msgKey, arg1);
Tr.error(tc, messageFromBundle);
}
}
|
java
|
public void displaySelectionPage(HttpServletRequest request, HttpServletResponse response, SocialTaiRequest socialTaiRequest) throws IOException {
setRequestAndConfigInformation(request, response, socialTaiRequest);
if (selectableConfigs == null || selectableConfigs.isEmpty()) {
sendDisplayError(response, "SIGN_IN_NO_CONFIGS", new Object[0]);
return;
}
generateOrSendToAppropriateSelectionPage(response);
}
|
java
|
String createJavascript() {
StringBuilder html = new StringBuilder();
html.append("<script>\n");
html.append("function " + createCookieFunctionName + "(value) {\n");
html.append("document.cookie = \"" + ClientConstants.LOGIN_HINT + "=\" + value;\n");
html.append("}\n");
html.append("</script>\n");
return html.toString();
}
|
java
|
public boolean parseMessage(WsByteBuffer buffer, boolean bExtractValue) throws Exception {
final boolean bTrace = TraceComponent.isAnyTracingEnabled();
boolean rc = false;
if (!isFirstLineComplete()) {
if (bTrace && tc.isDebugEnabled()) {
Tr.debug(tc, "Parsing First Line");
}
rc = parseLine(buffer);
}
// if we've read the first line, then parse the headers
// Note: we may come in with it true or it might be set to true above
if (isFirstLineComplete()) {
// keep parsing headers until that returns the "finished" response
rc = parseHeaders(buffer, bExtractValue);
}
if (bTrace && tc.isDebugEnabled()) {
Tr.debug(tc, "parseMessage returning " + rc);
}
return rc;
}
|
java
|
public WsByteBuffer[] marshallMessage() throws MessageSentException {
final boolean bTrace = TraceComponent.isAnyTracingEnabled();
if (bTrace && tc.isEntryEnabled()) {
Tr.entry(tc, "marshallMessage");
}
preMarshallMessage();
WsByteBuffer[] marshalledObj = hasFirstLineChanged() ? marshallLine() : null;
headerComplianceCheck();
marshalledObj = marshallHeaders(marshalledObj);
postMarshallMessage();
if (bTrace && tc.isEntryEnabled()) {
Tr.exit(tc, "marshallMessage");
}
return marshalledObj;
}
|
java
|
public static URITemplate createTemplate(Path path, List<Parameter> params, String classNameandPath) {
return createTemplate(path == null ? null : path.value(), params, classNameandPath);
}
|
java
|
private boolean isELReserved(String id) {
int i = 0;
int j = reservedWords.length;
while (i < j) {
int k = (i + j) / 2;
int result = reservedWords[k].compareTo(id);
if (result == 0) {
return true;
}
if (result < 0) {
i = k + 1;
} else {
j = k;
}
}
return false;
}
|
java
|
@Override
protected synchronized Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException {
synchronized (getClassLoadingLock(name)) {
Class<?> result = null;
if (name == null || name.length() == 0)
return null;
result = findLoadedClass(name);
if (result == null) {
if (name.regionMatches(0, BootstrapChildFirstJarClassloader.KERNEL_BOOT_CLASS_PREFIX, 0,
BootstrapChildFirstJarClassloader.KERNEL_BOOT_PREFIX_LENGTH)) {
result = super.loadClass(name, resolve);
} else {
try {
// Try to load the class from this classpath
result = findClass(name);
} catch (ClassNotFoundException cnfe) {
result = super.loadClass(name, resolve);
}
}
}
return result;
}
}
|
java
|
private static List<Integer> allocateOffsets(List<List<Integer>> offsetsStorage) {
if ( offsetsStorage.isEmpty() ) {
return new ArrayList<Integer>();
} else {
return ( offsetsStorage.remove(0) );
}
}
|
java
|
private static int[] releaseOffsets(List<List<Integer>> offsetsStorage, List<Integer> offsets) {
int numValues = offsets.size();
int[] extractedValues;
if ( numValues == 0 ) {
extractedValues = EMPTY_OFFSETS_ARRAY;
} else {
extractedValues = new int[numValues];
for ( int valueNo = 0; valueNo < numValues; valueNo++ ) {
extractedValues[valueNo] = offsets.get(valueNo).intValue();
}
}
offsets.clear();
offsetsStorage.add(offsets);
return extractedValues;
}
|
java
|
@Trivial
public static Map<String, IteratorData> collectIteratorData(ZipEntryData[] zipEntryData) {
Map<String, IteratorData> allNestingData = new HashMap<String, IteratorData>();
// Re-use offset lists. There can be a lot of these
// created for a busy tree. Offset lists are only needed
// for entries from the current entry back to the root.
List<List<Integer>> offsetsStorage = new ArrayList<List<Integer>>(32);
String r_lastPath = ""; // Root
int r_lastPathLen = 0;
List<Integer> offsets = EMPTY_OFFSETS;
int nestingDepth = 0;
List<String> r_pathStack = new ArrayList<String>(32);
List<List<Integer>> offsetsStack = new ArrayList<List<Integer>>(32);
for ( int nextOffset = 0; nextOffset < zipEntryData.length; nextOffset++ ) {
String r_nextPath = zipEntryData[nextOffset].r_getPath();
int r_nextPathLen = r_nextPath.length();
// The next path may be on a different branch.
//
// Backup until a common branch is located, emitting nesting data
// for each branch we cross.
while ( !isChildOf(r_nextPath, r_nextPathLen, r_lastPath, r_lastPathLen) ) {
if ( offsets != EMPTY_OFFSETS ) {
allNestingData.put(
r_lastPath,
new IteratorData( r_lastPath, releaseOffsets(offsetsStorage, offsets) ) );
}
nestingDepth--;
r_lastPath = r_pathStack.remove(nestingDepth);
r_lastPathLen = r_lastPath.length();
offsets = offsetsStack.remove(nestingDepth);
}
// The entry is now guaranteed to be on the
// same branch as the last entry.
//
// But, the entry be more than one nesting level
// deeper than the last entry.
//
// Create and add new offset collections for each
// new nesting level. There may be additional
// entries for the new nesting levels besides the
// entry.
Integer nextOffsetObj = Integer.valueOf(nextOffset);
int lastSlashLoc = r_lastPathLen + 1;
while ( lastSlashLoc != -1 ) {
int nextSlashLoc = r_nextPath.indexOf('/', lastSlashLoc);
String r_nextPartialPath;
int r_nextPartialPathLen;
if ( nextSlashLoc == -1 ) {
r_nextPartialPath = r_nextPath;
r_nextPartialPathLen = r_nextPathLen;
lastSlashLoc = nextSlashLoc;
} else {
r_nextPartialPath = r_nextPath.substring(0, nextSlashLoc);
r_nextPartialPathLen = nextSlashLoc;
lastSlashLoc = nextSlashLoc + 1;
}
if ( offsets == EMPTY_OFFSETS ) {
offsets = allocateOffsets(offsetsStorage);
}
offsets.add(nextOffsetObj);
nestingDepth++;
r_pathStack.add(r_lastPath);
offsetsStack.add(offsets);
r_lastPath = r_nextPartialPath;
r_lastPathLen = r_nextPartialPathLen;
offsets = EMPTY_OFFSETS;
}
}
// Usually, we are left some nestings beneath the root.
//
// Finish off each of those nestings.
while ( nestingDepth > 0 ) {
if ( offsets != EMPTY_OFFSETS ) {
allNestingData.put(
r_lastPath,
new IteratorData( r_lastPath, releaseOffsets(offsetsStorage, offsets) ) );
}
nestingDepth--;
r_lastPath = r_pathStack.remove(nestingDepth);
offsets = offsetsStack.remove(nestingDepth);
}
// If root data remains, finish that off too.
if ( offsets != EMPTY_OFFSETS ) {
allNestingData.put(
r_lastPath,
new IteratorData( r_lastPath, releaseOffsets(offsetsStorage, offsets) ) );
}
return allNestingData;
}
|
java
|
@Trivial
public static ZipEntryData[] collectZipEntries(ZipFile zipFile) {
final List<ZipEntryData> entriesList = new ArrayList<ZipEntryData>();
final Enumeration<? extends ZipEntry> zipEntries = zipFile.entries();
while ( zipEntries.hasMoreElements() ) {
entriesList.add( createZipEntryData( zipEntries.nextElement() ) );
}
ZipEntryData[] entryData = entriesList.toArray( new ZipEntryData[ entriesList.size() ] );
Arrays.sort(entryData, ZIP_ENTRY_DATA_COMPARATOR);
return entryData;
}
|
java
|
@Trivial
public static Map<String, ZipEntryData> setLocations(ZipEntryData[] entryData) {
Map<String, ZipEntryData> entryDataMap = new HashMap<String, ZipEntryData>(entryData.length);
for ( int entryNo = 0; entryNo < entryData.length; entryNo++ ) {
ZipEntryData entry = entryData[entryNo];
entry.setOffset(entryNo);
entryDataMap.put(entry.r_path, entry);
}
return entryDataMap;
}
|
java
|
@Trivial
public static int locatePath(ZipEntryData[] entryData, final String r_path) {
ZipEntryData targetData = new SearchZipEntryData(r_path);
// Given:
//
// 0 gp
// 1 gp/p1
// 2 gp/p1/c1
// 3 gp/p2/c2
//
// A search for "a" answers "-1" (inexact; insertion point is 0)
// A search for "gp" answers "0" (exact)
// A search for "gp/p1/c1" answers "2" (exact)
// A search for "gp/p1/c0" answers "-3" (inexact; insertion point is 2)
// A search for "z" answers "-5" (inexact; insertion point is 4)
return Arrays.binarySearch(
entryData,
targetData,
ZipFileContainerUtils.ZIP_ENTRY_DATA_COMPARATOR);
}
|
java
|
@Trivial
private static String stripPath(String path) {
int pathLen = path.length();
if ( pathLen == 0 ) {
return path;
} else if ( pathLen == 1 ) {
if ( path.charAt(0) == '/' ) {
return "";
} else {
return path;
}
} else {
if ( path.charAt(0) == '/' ) {
if ( path.charAt(pathLen - 1) == '/' ) {
return path.substring(1, pathLen - 1);
} else {
return path.substring(1, pathLen);
}
} else {
if ( path.charAt(pathLen - 1) == '/' ) {
return path.substring(0, pathLen - 1);
} else {
return path;
}
}
}
}
|
java
|
private static String getDeepestNestedElementName(String configDisplayId) {
int start = configDisplayId.lastIndexOf("]/");
if (start > 1) {
int end = configDisplayId.indexOf('[', start += 2);
if (end > start)
return configDisplayId.substring(start, end);
}
return null;
}
|
java
|
public void dump_memory(Writer out)
throws IOException
{
int qlist_num;
out.write("First quick size: " + first_quick_size + "\n");
out.write("Last quick size: " + last_quick_size + "\n");
out.write("Grain size: " + grain_size + "\n");
out.write("Acceptable waste: " + acceptable_waste + "\n");
out.write("Tail pointer in memory: " + tail_ptr + "\n");
out.write("First allocatable byte: " + start() + "\n\n");
out.write("Free lists from memory structures\n");
for (qlist_num = 0; qlist_num <= last_ql_index;
qlist_num++) {
out.write(qlist_num + ": ");
out.write("Length = " +
ql_heads[qlist_num].length + "; ");
print_memory_freelist(out, ql_heads[qlist_num].first_block);
};
out.write("Nonempty free lists: " + nonempty_lists + "\n");
out.write("Tail pointer in memory: " + tail_ptr + "\n");
out.write("First allocatable byte: " + start() + "\n\n");
}
|
java
|
protected Channel createChannel(ChannelData config) throws ChannelException
{
if (tc.isEntryEnabled()) SibTr.entry(this, tc, "createChannel", config);
Channel retChannel;
if (config.isInbound())
{
if (tc.isDebugEnabled()) SibTr.debug(this, tc, "createChannel", "inbound");
try
{
Class clazz = Class.forName(JFapChannelConstants.INBOUND_CHANNEL_CLASS);
Constructor contruct = clazz.getConstructor(new Class[]
{
ChannelFactoryData.class,
ChannelData.class
});
retChannel = (Channel) contruct.newInstance(new Object[]
{
channelFactoryData,
config
});
}
catch (Exception e)
{
FFDCFilter.processException(e,
"com.ibm.ws.sib.jfapchannel.impl.JFapChannelFactory.createChannel",
JFapChannelConstants.JFAPCHANNELFACT_CREATECHANNEL_01,
this);
if (tc.isDebugEnabled()) SibTr.debug(this, tc, "Unable to instantiate inbound channel", e);
// Rethrow as a channel exception
throw new ChannelException(e);
}
}
else
{
retChannel = new JFapChannelOutbound(channelFactoryData, config);
}
if (tc.isEntryEnabled()) SibTr.exit(this, tc, "createChannel", retChannel);
return retChannel;
}
|
java
|
public Class[] getDeviceInterface() // F177053
{
if (tc.isEntryEnabled()) SibTr.entry(this, tc, "getDeviceInterface"); // F177053
// Start D232185
if (devSideInterfaceClasses == null)
{
devSideInterfaceClasses = new Class[1];
devSideInterfaceClasses[0] = com.ibm.wsspi.tcpchannel.TCPConnectionContext.class; // f167363, F184828, F189000
}
// End D232185
if (tc.isEntryEnabled()) SibTr.exit(this, tc, "getDeviceInterface", devSideInterfaceClasses); // F177053
return devSideInterfaceClasses;
}
|
java
|
private void addRepository(String repositoryId, RepositoryWrapper repositoryHolder) {
repositories.put(repositoryId, repositoryHolder);
try {
numRepos = getNumberOfRepositories();
} catch (WIMException e) {
// okay
}
}
|
java
|
protected String getRepositoryIdByUniqueName(String uniqueName) throws WIMException {
boolean isDn = UniqueNameHelper.isDN(uniqueName) != null;
if (isDn)
uniqueName = UniqueNameHelper.getValidUniqueName(uniqueName).trim();
String repo = null;
int repoMatch = -1;
int bestMatch = -1;
for (Map.Entry<String, RepositoryWrapper> entry : repositories.entrySet()) {
repoMatch = entry.getValue().isUniqueNameForRepository(uniqueName, isDn);
if (repoMatch == Integer.MAX_VALUE) {
return entry.getKey();
} else if (repoMatch > bestMatch) {
repo = entry.getKey();
bestMatch = repoMatch;
}
}
if (repo != null) {
return repo;
}
AuditManager auditManager = new AuditManager();
Audit.audit(Audit.EventID.SECURITY_MEMBER_MGMT_01, auditManager.getRESTRequest(), auditManager.getRequestType(), auditManager.getRepositoryId(), uniqueName,
vmmService.getConfigManager().getDefaultRealmName(), null, Integer.valueOf("204"));
throw new InvalidUniqueNameException(WIMMessageKey.ENTITY_NOT_IN_REALM_SCOPE, Tr.formatMessage(
tc,
WIMMessageKey.ENTITY_NOT_IN_REALM_SCOPE,
WIMMessageHelper.generateMsgParms(uniqueName, "defined")));
}
|
java
|
@Override
public boolean isSameExecutionZone(FailureScope anotherScope)
{
if (tc.isEntryEnabled())
Tr.entry(tc, "isSameExecutionZone", anotherScope);
boolean isSameZone = equals(anotherScope);
if (tc.isEntryEnabled())
Tr.exit(tc, "isSameExecutionZone", new Boolean(isSameZone));
return isSameZone;
}
|
java
|
public static String encodeCookie(String string) {
if (string == null) {
return null;
}
string = string.replaceAll("%", "%25");
string = string.replaceAll(";", "%3B");
string = string.replaceAll(",", "%2C");
return string;
}
|
java
|
public static String decodeCookie(String string) {
if (string == null) {
return null;
}
string = string.replaceAll("%2C", ",");
string = string.replaceAll("%3B", ";");
string = string.replaceAll("%25", "%");
return string;
}
|
java
|
@Trivial
public static String getRequestStringForTrace(HttpServletRequest request, String[] secretStrings) {
if (request == null || request.getRequestURL() == null) {
return "[]";
}
StringBuffer sb = new StringBuffer("[" + stripSecretsFromUrl(request.getRequestURL().toString(), secretStrings) + "]");
String query = request.getQueryString();
if (query != null) {
String queryString = stripSecretsFromUrl(query, secretStrings);
if (queryString != null) {
sb.append(", queryString[" + queryString + "]");
}
} else {
Map<String, String[]> pMap = request.getParameterMap();
String paramString = stripSecretsFromParameters(pMap, secretStrings);
if (paramString != null) {
sb.append(", parameters[" + paramString + "]");
}
}
return sb.toString();
}
|
java
|
public void deleteAbstractAliasDestinationHandler(AbstractAliasDestinationHandler abstractAliasDestinationHandler)
{
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
SibTr.entry(tc, "deleteAbstractAliasDestinationHandler");
//The destination is an alias or a foreign destination, so its not persisted
//It is removed immediately from the appropriate index
if(abstractAliasDestinationHandler instanceof BusHandler)
{
_foreignBusIndex.remove(abstractAliasDestinationHandler);
}
else
{
_destinationIndex.remove(abstractAliasDestinationHandler);
}
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
SibTr.exit(tc, "deleteAbstractAliasDestinationHandler");
}
|
java
|
public int add(Object dependency, ValueSet valueSet, Object entry) {
int returnCode = HTODDynacache.NO_EXCEPTION;
dependencyNotUpdatedTable.remove(dependency);
valueSet.add(entry);
if (valueSet.size() > this.delayOffloadEntriesLimit) {
if (this.type == DEP_ID_TABLE) {
returnCode = this.htod.writeValueSet(HTODDynacache.DEP_ID_DATA, dependency, valueSet, HTODDynacache.ALL); // valueSet may be empty after writeValueSet
this.htod.cache.getCacheStatisticsListener().depIdsOffloadedToDisk(dependency);
if (tc.isDebugEnabled())
Tr.debug(tc, "***** add dependency id=" + dependency + " size=" + valueSet.size());
} else {
returnCode = this.htod.writeValueSet(HTODDynacache.TEMPLATE_ID_DATA, dependency, valueSet, HTODDynacache.ALL); // valueSet may be empty after writeValueSet
this.htod.cache.getCacheStatisticsListener().templatesOffloadedToDisk(dependency);
if (tc.isDebugEnabled())
Tr.debug(tc, "***** add dependency id=" + dependency + " size=" + valueSet.size());
}
dependencyToEntryTable.remove(dependency);
if (returnCode == HTODDynacache.DISK_SIZE_OVER_LIMIT_EXCEPTION && valueSet.size() > 0) {
this.htod.delCacheEntry(valueSet, CachePerf.DISK_OVERFLOW, CachePerf.LOCAL,
!Cache.FROM_DEPID_TEMPLATE_INVALIDATION,
HTODInvalidationBuffer.FIRE_EVENT);
returnCode = HTODDynacache.NO_EXCEPTION;
}
}
return returnCode;
}
|
java
|
public int add(Object dependency, ValueSet valueSet) {
int returnCode = HTODDynacache.NO_EXCEPTION;
if (dependencyToEntryTable.size() >= this.maxSize) {
returnCode = reduceTableSize();
}
dependencyNotUpdatedTable.put(dependency, valueSet);
dependencyToEntryTable.put(dependency, valueSet);
return returnCode;
}
|
java
|
public int replace(Object dependency, ValueSet valueSet) {
int returnCode = HTODDynacache.NO_EXCEPTION;
dependencyNotUpdatedTable.remove(dependency);
if (valueSet != null && valueSet.size() > this.delayOffloadEntriesLimit) {
dependencyToEntryTable.remove(dependency);
if (this.type == DEP_ID_TABLE) {
returnCode = this.htod.writeValueSet(HTODDynacache.DEP_ID_DATA, dependency, valueSet, HTODDynacache.ALL); // valueSet may be empty after writeValueSet
this.htod.cache.getCacheStatisticsListener().depIdsOffloadedToDisk(dependency);
//System.out.println("***** replace dependency id=" + dependency + " size=" + valueSet.size());
} else {
returnCode = this.htod.writeValueSet(HTODDynacache.TEMPLATE_ID_DATA, dependency, valueSet, HTODDynacache.ALL); // valueSet may be empty after writeValueSet
this.htod.cache.getCacheStatisticsListener().templatesOffloadedToDisk(dependency);
//System.out.println("***** replace template id=" + dependency + " size=" + valueSet.size());
}
} else {
if (valueSet.size() > 0) {
dependencyToEntryTable.put(dependency, valueSet);
} else {
dependencyToEntryTable.remove(dependency);
}
}
if (returnCode == HTODDynacache.DISK_SIZE_OVER_LIMIT_EXCEPTION && valueSet.size() > 0) {
this.htod.delCacheEntry(valueSet, CachePerf.DISK_OVERFLOW, CachePerf.LOCAL,
!Cache.FROM_DEPID_TEMPLATE_INVALIDATION,
HTODInvalidationBuffer.FIRE_EVENT);
returnCode = HTODDynacache.NO_EXCEPTION;
}
return returnCode;
}
|
java
|
public Result removeEntry(Object dependency, Object entry) {
Result result = this.htod.getFromResultPool();
ValueSet valueSet = (ValueSet) dependencyToEntryTable.get(dependency);
if (valueSet == null) {
return result;
}
result.bExist = HTODDynacache.EXIST;
valueSet.remove(entry);
dependencyNotUpdatedTable.remove(dependency);
if (valueSet.isEmpty()) {
dependencyToEntryTable.remove(dependency);
if (this.type == DEP_ID_TABLE) {
result.returnCode = this.htod.delValueSet(HTODDynacache.DEP_ID_DATA, dependency);
} else {
result.returnCode = this.htod.delValueSet(HTODDynacache.TEMPLATE_ID_DATA, dependency);
}
}
return result;
}
|
java
|
public ValueSet getEntries(Object dependency) {
ValueSet valueSet = (ValueSet) dependencyToEntryTable.get(dependency);
return valueSet;
}
|
java
|
private int reduceTableSize() {
int returnCode = HTODDynacache.NO_EXCEPTION;
int count = this.entryRemove;
if (count > 0) {
int removeSize = 5;
while (count > 0) {
int minSize = Integer.MAX_VALUE;
Iterator<Map.Entry<Object,Set<Object>>> e = dependencyToEntryTable.entrySet().iterator();
while (e.hasNext()) {
Map.Entry entry = (Map.Entry) e.next();
Object id = entry.getKey();
ValueSet vs = (ValueSet) entry.getValue();
int vsSize = vs.size();
if (vsSize < removeSize) {
if (this.type == DEP_ID_TABLE) {
returnCode = this.htod.writeValueSet(HTODDynacache.DEP_ID_DATA, id, vs, HTODDynacache.ALL); // valueSet may be empty after writeValueSet
this.htod.cache.getCacheStatisticsListener().depIdsOffloadedToDisk(id);
Tr.debug(tc, " reduceTableSize dependency id=" + id + " vs=" + vs.size() + " returnCode="+returnCode);
} else {
returnCode = this.htod.writeValueSet(HTODDynacache.TEMPLATE_ID_DATA, id, vs, HTODDynacache.ALL); // valueSet may be empty after writeValueSet
this.htod.cache.getCacheStatisticsListener().templatesOffloadedToDisk(id);
Tr.debug(tc,"reduceTableSize template id=" + id + " vs=" + vs.size() + " returnCode="+returnCode);
}
dependencyToEntryTable.remove(id);
dependencyNotUpdatedTable.remove(id);
count--;
if (returnCode == HTODDynacache.DISK_EXCEPTION) {
return returnCode;
} else if (returnCode == HTODDynacache.DISK_SIZE_OVER_LIMIT_EXCEPTION) {
this.htod.delCacheEntry(vs, CachePerf.DISK_OVERFLOW, CachePerf.LOCAL,
!Cache.FROM_DEPID_TEMPLATE_INVALIDATION,
HTODInvalidationBuffer.FIRE_EVENT);
returnCode = HTODDynacache.NO_EXCEPTION;
return returnCode;
}
} else {
minSize = vsSize < minSize ? vsSize : minSize;
}
if (count == 0) {
break;
}
}
removeSize = minSize;
removeSize += 3;
}
}
return returnCode;
}
|
java
|
private static String getClassName(String implClassName) {
implClassName = implClassName.substring(0, implClassName.length() - 4);
return implClassName + "ComponentImpl";
}
|
java
|
public void registerThread(StoppableThread thread)
{
if (tc.isEntryEnabled())
SibTr.entry(tc, "registerThread", thread);
synchronized (this)
{
_threadCache.add(thread);
}
if (tc.isEntryEnabled())
SibTr.exit(tc, "registerThread");
}
|
java
|
public void deregisterThread(StoppableThread thread)
{
if (tc.isEntryEnabled())
SibTr.entry(tc, "deregisterThread", thread);
synchronized (this)
{
_threadCache.remove(thread);
}
if (tc.isEntryEnabled())
SibTr.exit(tc, "deregisterThread");
}
|
java
|
public void stopAllThreads()
{
if (tc.isEntryEnabled())
SibTr.entry(tc, "stopAllThreads");
synchronized (this)
{
Iterator iterator = ((ArrayList)_threadCache.clone()).iterator();
while (iterator.hasNext())
{
StoppableThread thread = (StoppableThread)iterator.next();
if (tc.isDebugEnabled())
SibTr.debug(tc, "Attempting to stop thread " + thread);
// Stop the thread
thread.stopThread(this);
// Remove from the iterator
iterator.remove();
// Remove from the cache
_threadCache.remove(thread);
}
}
if (tc.isEntryEnabled())
SibTr.exit(tc, "stopAllThreads");
}
|
java
|
public ArrayList getThreads()
{
if (tc.isEntryEnabled())
{
SibTr.entry(tc, "getThreads");
SibTr.exit(tc, "getThreads", _threadCache);
}
return _threadCache;
}
|
java
|
private int getAndUpdateTail() {
int retMe;
do {
retMe = tailIndex.get();
} while (tailIndex.compareAndSet(retMe, getNext(retMe)) == false);
return retMe;
}
|
java
|
public boolean put(ExpirableReference expirable)
{
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(this, tc, "put", "ObjId=" + expirable.getID() + " ET=" + expirable.getExpiryTime());
boolean reply = tree.insert(expirable);
if (reply)
{
size++;
}
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(this, tc, "put", "reply=" + reply);
return reply;
}
|
java
|
protected static Map<String, ProductInfo> getAllProductInfo(File wlpInstallationDirectory) throws VersionParsingException {
File versionPropertyDirectory = new File(wlpInstallationDirectory, ProductInfo.VERSION_PROPERTY_DIRECTORY);
if (!versionPropertyDirectory.exists()) {
throw new VersionParsingException(CommandUtils.getMessage("ERROR_NO_PROPERTIES_DIRECTORY", versionPropertyDirectory.getAbsoluteFile()));
}
if (!versionPropertyDirectory.isDirectory()) {
throw new VersionParsingException(CommandUtils.getMessage("ERROR_NOT_PROPERTIES_DIRECTORY", versionPropertyDirectory.getAbsoluteFile()));
}
if (!versionPropertyDirectory.canRead()) {
throw new VersionParsingException(CommandUtils.getMessage("ERROR_UNABLE_READ_PROPERTIES_DIRECTORY", versionPropertyDirectory.getAbsoluteFile()));
}
Map<String, ProductInfo> productIdToVersionPropertiesMap;
try {
productIdToVersionPropertiesMap = ProductInfo.getAllProductInfo(wlpInstallationDirectory);
} catch (IllegalArgumentException e) {
throw new VersionParsingException(CommandUtils.getMessage("ERROR_UNABLE_READ_PROPERTIES_DIRECTORY", versionPropertyDirectory.getAbsoluteFile()));
} catch (ProductInfoParseException e) {
String missingKey = e.getMissingKey();
if (missingKey != null) {
throw new VersionParsingException(CommandUtils.getMessage("version.missing.key", missingKey, e.getFile().getAbsoluteFile()));
}
throw new VersionParsingException(CommandUtils.getMessage("ERROR_UNABLE_READ_FILE", e.getFile().getAbsoluteFile(), e.getCause().getMessage()));
} catch (DuplicateProductInfoException e) {
throw new VersionParsingException(CommandUtils.getMessage("version.duplicated.productId",
ProductInfo.COM_IBM_WEBSPHERE_PRODUCTID_KEY,
e.getProductInfo1().getFile().getAbsoluteFile(),
e.getProductInfo2().getFile().getAbsoluteFile()));
} catch (ProductInfoReplaceException e) {
ProductInfo productInfo = e.getProductInfo();
String replacesId = productInfo.getReplacesId();
if (replacesId.equals(productInfo.getId())) {
throw new VersionParsingException(CommandUtils.getMessage("version.replaced.product.can.not.itself", productInfo.getFile().getAbsoluteFile()));
}
throw new VersionParsingException(CommandUtils.getMessage("version.replaced.product.not.exist", replacesId, productInfo.getFile().getAbsoluteFile()));
}
if (productIdToVersionPropertiesMap.isEmpty()) {
throw new VersionParsingException(CommandUtils.getMessage("ERROR_NO_PROPERTIES_FILE", versionPropertyDirectory.getAbsoluteFile()));
}
return productIdToVersionPropertiesMap;
}
|
java
|
public boolean remove(V value) {
// peek at what is in the map
K key = value.getKey();
Ref<V> ref = map.get(key);
// only try to remove the mapping if it matches the provided class loader
return (ref != null && ref.get() == value) ? map.remove(key, ref) : false;
}
|
java
|
public V retrieveOrCreate(K key, Factory<V> factory) {
// Clean up stale entries on every put.
// This should avoid a slow memory leak of reference objects.
this.cleanUpStaleEntries();
return retrieveOrCreate(key, factory, new FutureRef<V>());
}
|
java
|
void cleanUpStaleEntries() {
for (KeyedRef<K, V> ref = q.poll(); ref != null; ref = q.poll()) {
map.remove(ref.getKey(), ref); // CONCURRENT remove() operation
}
}
|
java
|
public Object nextElement()
{
if (_array == null)
{
return null;
}
else
{
synchronized(this){
if (_index < _array.length)
{
Object obj = _array[_index];
_index++;
return obj;
}
else
{
return null;
}
}
}
}
|
java
|
public int execute(String[] args) {
Map<String, LevelDetails> levels = readLevels(System.getProperty("logviewer.custom.levels"));
String[] header = readHeader(System.getProperty("logviewer.custom.header"));
return execute(args, levels, header);
}
|
java
|
public int execute(String[] args, Map<String, LevelDetails> levels, String[] header) {
levelString = getLevelsString(levels);
RepositoryReaderImpl logRepository;
try {
// Parse the command line arguments and validate arguments
if (parseCmdLineArgs(args) || validateSettings()) {
return 0;
}
// Setup custom header here since parseCmdLineArgs may alter the formatter.
if (header != null) {
theFormatter.setCustomHeader(header);
}
// Call HPEL repository API to get log entries
logRepository = new RepositoryReaderImpl(binaryRepositoryDir);
if (mainInstanceId != null) {
// Verify requested instance ID.
ServerInstanceLogRecordList silrl = logRepository.getLogListForServerInstance(mainInstanceId);
if (silrl == null || silrl.getStartTime() == null || !silrl.getStartTime().equals(mainInstanceId) ||
(subInstanceId != null && !subInstanceId.isEmpty() && !silrl.getChildren().containsKey(subInstanceId))) {
throw new IllegalArgumentException(getLocalizedString("LVM_ERROR_INSTANCEID"));
}
}
// Create the output stream (either an output file or Console)
PrintStream outps = createOutputStream();
/*
* Create a filter object with our search criteria, passing null for startDate and stopDate as we will
* be using the API to search by date for efficiency.
*/
LogViewerFilter searchCriteria = new LogViewerFilter(startDate, stopDate, minLevel, maxLevel, includeLoggers, excludeLoggers, hexThreadID, message, excludeMessages, extensions);
//Determine if we just display instances or start displaying records based on the -listInstances option
if (listInstances) {
Iterable<ServerInstanceLogRecordList> results = logRepository.getLogLists();
displayInstances(outps, results);
} else {
Properties initialProps = logRepository.getLogListForCurrentServerInstance().getHeader();
if (initialProps != null) {
boolean isZOS = "Y".equalsIgnoreCase(initialProps.getProperty(ServerInstanceLogRecordList.HEADER_ISZOS));
//instanceId is required for z/OS. If it was not provided, then list the possible instances
if (isZOS && !latestInstance && mainInstanceId == null) {
Iterable<ServerInstanceLogRecordList> results = logRepository.getLogLists();
displayInstances(outps, results);
} else {
displayRecords(outps, searchCriteria, logRepository, mainInstanceId, subInstanceId);
}
}
}
} catch (IllegalArgumentException e) {
System.err.println(e.getMessage());
return 1;
}
return 0;
}
|
java
|
private long collectAllKids(ArrayList<DisplayInstance> result, ServerInstanceLogRecordList list) {
long timestamp = -1;
RepositoryLogRecord first = list.iterator().next();
if (first != null) {
timestamp = first.getMillis();
}
for (Entry<String, ServerInstanceLogRecordList> kid : list.getChildren().entrySet()) {
ArrayList<DisplayInstance> kidResult = new ArrayList<DisplayInstance>();
long curTimestamp = collectAllKids(kidResult, kid.getValue());
// Add this kid only if there's a record among its descendants
if (curTimestamp > 0) {
result.add(new DisplayInstance(kid.getKey(), Long.toString(list.getStartTime().getTime()), curTimestamp, kidResult));
if (timestamp < curTimestamp) {
timestamp = curTimestamp;
}
}
}
return timestamp;
}
|
java
|
private Level createLevelByString(String levelString) throws IllegalArgumentException {
try {
return Level.parse(levelString.toUpperCase());
//return WsLevel.parse(levelString.toUpperCase());
} catch (Exception npe) {
throw new IllegalArgumentException(getLocalizedParmString("CWTRA0013E", new Object[] { levelString }));
}
}
|
java
|
void setInstanceId(String instanceId) throws IllegalArgumentException {
if (instanceId != null && !"".equals(instanceId)) {
subInstanceId = getSubProcessInstanceId(instanceId);
try {
long id = getProcessInstanceId(instanceId);
mainInstanceId = id < 0 ? null : new Date(id);
} catch (NumberFormatException nfe) {
throw new IllegalArgumentException(getLocalizedString("LVM_ERROR_INSTANCEID"), nfe);
}
}
}
|
java
|
protected File[] listRepositoryChoices() {
// check current location
String currentDir = System.getProperty("log.repository.root");
if (currentDir == null)
currentDir = System.getProperty("user.dir");
File logDir = new File(currentDir);
if (logDir.isDirectory()) {
File[] result = RepositoryReaderImpl.listRepositories(logDir);
if (result.length == 0 && (RepositoryReaderImpl.containsLogFiles(logDir) || tailInterval > 0)) {
return new File[] { logDir };
} else {
return result;
}
} else {
return new File[] {};
}
}
|
java
|
private int skipPast(byte[] data, int pos, byte target) {
int index = pos;
while (index < data.length) {
if (target == data[index++]) {
return index;
}
}
return index;
}
|
java
|
private int parseTrailer(byte[] input, int inOffset, List<WsByteBuffer> list) throws DataFormatException {
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
Tr.debug(tc, "Parsing trailer, offset=" + this.parseOffset + " val=" + this.parseInt);
}
int offset = inOffset;
long val = 0L;
// bytes are in lowest order first
while (8 > this.parseOffset && offset < input.length) {
switch (this.parseOffset) {
// even bytes are just going to save the first byte of an int
case 0:
case 2:
case 4:
case 6:
this.parseFirstByte = input[offset] & 0xff;
break;
// bytes 1 and 5 are the 2nd byte of that int
case 1:
case 5:
this.parseInt = ((input[offset] & 0xff) << 8) | this.parseFirstByte;
break;
// 3 and 7 mark the final bytes of the 2 int values
case 3:
// reached the end of the checksum int
val = ((input[offset] & 0xff) << 8) | this.parseFirstByte;
val = (val << 16) | this.parseInt;
if (this.checksum.getValue() != val) {
String msg = "Checksum does not match; crc=" + this.checksum.getValue() + " trailer=" + val;
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
Tr.debug(tc, msg);
}
release(list);
throw new DataFormatException(msg);
}
break;
case 7:
// reached the end of the "num bytes" int
val = ((input[offset] & 0xff) << 8) | this.parseFirstByte;
val = (val << 16) | this.parseInt;
if (this.inflater.getBytesWritten() != val) {
String msg = "BytesWritten does not match; inflater=" + this.inflater.getBytesWritten() + " trailer=" + val;
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
Tr.debug(tc, msg);
}
release(list);
throw new DataFormatException(msg);
}
// having fully parsed the trailer, if we are going to re-enter decompression, then we need to reset
this.resetNeededToProceed = true;
break;
default:
break;
}
offset++;
this.parseOffset++;
}
return offset;
}
|
java
|
public void logClosedException(Exception e) {
// Note: this may be a normal occurance so don't log error, just debug.
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
Tr.debug(tc, "Connection closed with exception: " + e.getMessage());
}
}
|
java
|
void outOfScope() {
final String methodName = "outOfScope";
if (TRACE.isEntryEnabled()) {
SibTr.entry(this, TRACE, methodName);
}
_outOfScope = true;
try {
// Close cloned connection so that it, and any resource created
// from it, also throw SIObjectClosedException
_connectionClone.close();
} catch (final SIException exception) {
FFDCFilter
.processException(
exception,
"com.ibm.ws.sib.ra.inbound.impl.SibRaAbstractConsumerSession.outOfScope",
FFDC_PROBE_1, this);
if (TRACE.isEventEnabled()) {
SibTr.exception(this, TRACE, exception);
}
// Swallow exception
} catch (final SIErrorException exception) {
FFDCFilter
.processException(
exception,
"com.ibm.ws.sib.ra.inbound.impl.SibRaAbstractConsumerSession.outOfScope",
FFDC_PROBE_2, this);
if (TRACE.isEventEnabled()) {
SibTr.exception(this, TRACE, exception);
}
// Swallow exception
}
if (TRACE.isEntryEnabled()) {
SibTr.exit(this, TRACE, methodName);
}
}
|
java
|
public void createAppToSecurityRolesMapping(String appName, Collection<SecurityRole> securityRoles) {
//only add it if we don't have a cached copy
appToSecurityRolesMap.putIfAbsent(appName, securityRoles);
}
|
java
|
public void removeRoleToRunAsMapping(String appName) {
Map<String, RunAs> roleToRunAsMap = roleToRunAsMappingPerApp.get(appName);
if (roleToRunAsMap != null) {
roleToRunAsMap.clear();
}
appToSecurityRolesMap.remove(appName);
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
Tr.debug(tc, "Updated the appToSecurityRolesMap: " + appToSecurityRolesMap.toString());
}
removeRoleToWarningMapping(appName);
}
|
java
|
public void removeRoleToWarningMapping(String appName) {
Map<String, Boolean> roleToWarningMap = roleToWarningMappingPerApp.get(appName);
if (roleToWarningMap != null) {
roleToWarningMap.clear();
}
roleToWarningMappingPerApp.remove(appName);
}
|
java
|
private static void determineHandlers() {
/*
* find the handlers that we are dispatching to
*/
if (textHandler != null && !logRepositoryConfiguration.isTextEnabled())
textHandler = null ;
// Don't do this work if only text and text is not enabled (if so, it will always be null) 666241.1
if (binaryHandler != null && !logRepositoryConfiguration.isTextEnabled())
return ;
Handler[] handlers = Logger.getLogger("").getHandlers();
for (Handler handler : handlers) {
String name = handler.getClass().getName();
if (BINLOGGER_HANDLER_NAME.equals(name)) {
binaryHandler = (LogRecordHandler) handler;
} else if (TEXTLOGGER_HANDLER_NAME.equals(name)) {
textHandler = (LogRecordTextHandler) handler;
}
}
}
|
java
|
public void close()
{
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(tc, "close");
Enumeration streams = null;
synchronized (this)
{
synchronized (streamTable)
{
closed = true;
closeBrowserSessionsInternal();
streams = streamTable.elements();
}
}
// since already set closed to true, no more AOStreams will be created and added to the streamTable,
// even if there is an
// asynchronous stream creation in progress (the itemStream will be created, but no AOStream will
// be added to the streamTable).
while (streams.hasMoreElements())
{
StreamInfo sinfo = (StreamInfo) streams.nextElement();
if (sinfo.stream != null)
{
sinfo.stream.close();
}
}
synchronized (streamTable)
{
streamTable.clear();
}
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(tc, "close");
}
|
java
|
public boolean cleanup(boolean flushStreams, boolean redriveDeletionThread)
{
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(tc, "cleanup",
new Object[]{Boolean.valueOf(flushStreams), Boolean.valueOf(redriveDeletionThread)});
boolean retvalue = false;
// first check if already finishedCloseAndFlush, since this call can be redriven
synchronized (streamTable)
{
if (finishedCloseAndFlush)
{
retvalue = true;
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(tc, "cleanup", Boolean.valueOf(retvalue));
return retvalue;
}
}
if (!flushStreams)
{
// Simply cleanup the non-persistent state. The persistent state will get cleaned up when
// the caller deletes everything from the AOContainerItemStream
close();
retvalue = true;
}
else
{
// have to flush all the streams
closeAndFlush(redriveDeletionThread);
synchronized (streamTable)
{
retvalue = finishedCloseAndFlush;
}
}
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(tc, "cleanup", Boolean.valueOf(retvalue));
return retvalue;
}
|
java
|
public final AOStream getAOStream(String streamKey, SIBUuid12 streamId)
{
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
SibTr.entry(tc, "getAOStream", new Object[]{streamKey, streamId});
StreamInfo streamInfo = getStreamInfo(streamKey, streamId);
if (streamInfo != null)
{
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(tc, "getAOStream", streamInfo.stream);
return streamInfo.stream;
}
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(tc, "getAOStream", null);
return null;
}
|
java
|
private final void handleControlBrowseStatus(SIBUuid8 remoteME, SIBUuid12 gatheringTargetDestUuid, long browseId, int status)
{
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
SibTr.entry(tc, "handleControlBrowseStatus",
new Object[] {remoteME, gatheringTargetDestUuid, Long.valueOf(browseId), Integer.valueOf(status)});
// first we see if there is an existing AOBrowseSession
AOBrowserSessionKey key = new AOBrowserSessionKey(remoteME, gatheringTargetDestUuid, browseId);
AOBrowserSession session = (AOBrowserSession) browserSessionTable.get(key);
if (session != null)
{
if (status == SIMPConstants.BROWSE_CLOSE)
{
session.close();
browserSessionTable.remove(key);
}
else if (status == SIMPConstants.BROWSE_ALIVE)
{
session.keepAlive();
}
}
else
{ // session == null. ignore the status message
}
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
SibTr.exit(tc, "handleControlBrowseStatus");
}
|
java
|
public final void removeBrowserSession(AOBrowserSessionKey key)
{
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
SibTr.entry(tc, "removeBrowserSession", key);
browserSessionTable.remove(key);
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
SibTr.exit(tc, "removeBrowserSession");
}
|
java
|
private final StreamInfo getStreamInfo(String streamKey, SIBUuid12 streamId)
{
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
SibTr.entry(tc, "getStreamInfo", new Object[]{streamKey, streamId});
StreamInfo sinfo = streamTable.get(streamKey);
if ((sinfo != null) && sinfo.streamId.equals(streamId))
{
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(tc, "getStreamInfo", sinfo);
return sinfo;
}
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(tc, "getStreamInfo", null);
return null;
}
|
java
|
public final void streamIsFlushed(AOStream stream)
{
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
SibTr.entry(tc, "streamIsFlushed", stream);
// we schedule an asynchronous removal of the persistent data
synchronized (streamTable)
{
String key = SIMPUtils.getRemoteGetKey(stream.getRemoteMEUuid(), stream.getGatheringTargetDestUuid());
StreamInfo sinfo = streamTable.get(key);
if ((sinfo != null) && sinfo.streamId.equals(stream.streamId))
{
RemovePersistentStream update = null;
synchronized (sinfo)
{ // synchronized since reading sinfo.item
update = new RemovePersistentStream(key, sinfo.streamId, sinfo.itemStream, sinfo.item);
}
doEnqueueWork(update);
}
}
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
SibTr.exit(tc, "streamIsFlushed");
}
|
java
|
public final AOValue persistLockAndTick(TransactionCommon t, AOStream stream, long tick,
SIMPMessage msg, int storagePolicy, long waitTime, long prevTick) throws Exception
{
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
SibTr.entry(tc, "persistLockAndTick",
new Object[] {t,
stream,
Long.valueOf(tick),
msg,
Integer.valueOf(storagePolicy),
Long.valueOf(waitTime),
Long.valueOf(prevTick)});
AOValue retvalue = null;
try
{
Transaction msTran = mp.resolveAndEnlistMsgStoreTransaction(t);
msg.persistLock(msTran);
long plockId = msg.getLockID();
retvalue = new AOValue(tick, msg, msg.getID(), storagePolicy,
plockId, waitTime, prevTick);
stream.itemStream.addItem(retvalue, msTran);
}
catch (Exception e)
{
// No FFDC code needed
retvalue = null;
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
SibTr.exit(tc, "persistLockAndTick", e);
throw e;
}
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
SibTr.exit(tc, "persistLockAndTick", retvalue);
return retvalue;
}
|
java
|
public final void cleanupTicks(StreamInfo sinfo, TransactionCommon t, ArrayList valueTicks) throws MessageStoreException, SIResourceException
{
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
SibTr.entry(tc, "cleanupTicks", new Object[]{sinfo, t, valueTicks});
try {
int length = valueTicks.size();
for (int i=0; i<length; i++)
{
AOValue storedTick = (AOValue) valueTicks.get(i);
// If we are here then we do not know which consumerDispatcher originally
// persistently locked the message. We therefore have to use the meUuid in
// the AOValue to find/reconstitute the consumerDispatcher associated with it. This
// potentially involves creating AIHs which is not ideal.
ConsumerDispatcher cd = null;
if (storedTick.getSourceMEUuid()==null ||
storedTick.getSourceMEUuid().equals(getMessageProcessor().getMessagingEngineUuid()))
{
cd = (ConsumerDispatcher)destinationHandler.getLocalPtoPConsumerManager();
}
else
{
AnycastInputHandler aih =
destinationHandler.getAnycastInputHandler(storedTick.getSourceMEUuid(), null, true);
cd = aih.getRCD();
}
SIMPMessage msg = null;
synchronized(storedTick)
{
msg = (SIMPMessage) cd.getMessageByValue(storedTick);
if (msg == null)
{
storedTick.setToBeFlushed();
}
}
Transaction msTran = mp.resolveAndEnlistMsgStoreTransaction(t);
if (msg!=null && msg.getLockID()==storedTick.getPLockId())
msg.unlockMsg(storedTick.getPLockId(), msTran, true);
storedTick.lockItemIfAvailable(controlItemLockID); // should always be successful
storedTick.remove(msTran, controlItemLockID);
}
}
catch (MessageStoreException e)
{
// No FFDC code needed
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
SibTr.exit(tc, "cleanupTicks", e);
throw e;
}
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
SibTr.exit(tc, "cleanupTicks");
}
|
java
|
public final Item writeStartedFlush(TransactionCommon t, AOStream stream) throws Exception
{
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
SibTr.entry(tc, "writeStartedFlush");
String key =
SIMPUtils.getRemoteGetKey(stream.getRemoteMEUuid(), stream.getGatheringTargetDestUuid());
StreamInfo sinfo = streamTable.get(key);
if ((sinfo != null) && sinfo.streamId.equals(stream.streamId))
{
AOStartedFlushItem item = new AOStartedFlushItem(key, stream.streamId);
Transaction msTran = mp.resolveAndEnlistMsgStoreTransaction(t);
this.containerItemStream.addItem(item, msTran);
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
SibTr.exit(tc, "writeStartedFlush", item);
return item;
}
// this should not occur
// log error and throw exception
SIErrorException e = new SIErrorException(
nls.getFormattedMessage(
"INTERNAL_MESSAGING_ERROR_CWSIP0001",
new Object[] { "com.ibm.ws.sib.processor.impl.AnycastOutputHandler", "1:2810:1.89.4.1" },
null));
// FFDC
FFDCFilter.processException(
e,
"com.ibm.ws.sib.processor.impl.AnycastOutputHandler.writeStartedFlush",
"1:2817:1.89.4.1",
this);
SibTr.exception(tc, e);
SibTr.error(tc, "INTERNAL_MESSAGING_ERROR_CWSIP0001",
new Object[] { "com.ibm.ws.sib.processor.impl.AnycastOutputHandler", "1:2822:1.89.4.1" });
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
SibTr.exit(tc, "writeStartedFlush", e);
throw e;
}
|
java
|
public final void writtenStartedFlush(AOStream stream, Item startedFlushItem)
{
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
SibTr.entry(tc, "writtenStartedFlush");
String key =
SIMPUtils.getRemoteGetKey(stream.getRemoteMEUuid(), stream.getGatheringTargetDestUuid());
StreamInfo sinfo = streamTable.get(key);
if ((sinfo != null) && sinfo.streamId.equals(stream.streamId))
{
synchronized (sinfo)
{
sinfo.item = (AOStartedFlushItem) startedFlushItem;
}
}
else
{
// this should not occur
// log error and throw exception
SIErrorException e = new SIErrorException(
nls.getFormattedMessage(
"INTERNAL_MESSAGING_ERROR_CWSIP0001",
new Object[] {
"com.ibm.ws.sib.processor.impl.AnycastOutputHandler",
"1:2858:1.89.4.1" },
null));
// FFDC
FFDCFilter.processException(
e,
"com.ibm.ws.sib.processor.impl.AnycastOutputHandler.writtenStartedFlush",
"1:2865:1.89.4.1",
this);
SibTr.exception(tc, e);
SibTr.error(tc, "INTERNAL_MESSAGING_ERROR_CWSIP0001",
new Object[] {
"com.ibm.ws.sib.processor.impl.AnycastOutputHandler",
"1:2872:1.89.4.1" });
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
SibTr.exit(tc, "writtenStartedFlush", e);
throw e;
}
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
SibTr.exit(tc, "writtenStartedFlush");
}
|
java
|
public SIMPItemStream getItemStream()
{
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
SibTr.entry(tc, "getItemStream");
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
SibTr.exit(tc, "getItemStream", containerItemStream);
return (SIMPItemStream) containerItemStream;
}
|
java
|
public final String getDestName()
{
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
SibTr.entry(tc, "getDestName");
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
SibTr.exit(tc, "getDestName", destName);
return destName;
}
|
java
|
public final SIBUuid12 getDestUUID()
{
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
{
SibTr.entry(tc, "getDestUUID");
SibTr.exit(tc, "getDestUUID", destName);
}
return destUuid;
}
|
java
|
public void forceFlushAtSource(SIBUuid8 remoteUuid, SIBUuid12 gatheringTargetDestUuid)
{
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
SibTr.entry(tc, "forceFlushAtSource", new Object[] {remoteUuid, gatheringTargetDestUuid});
StreamInfo sinfo;
boolean success = false;
String key =
SIMPUtils.getRemoteGetKey(remoteUuid, gatheringTargetDestUuid);
synchronized (streamTable)
{
sinfo = streamTable.get(key);
}
if (sinfo == null)
{ // need to do nothing as a stream for this RME does not exist
success = true;
}
else if (sinfo.stream == null)
{
// stream for this RME is being created, which means that the RME just sent a request
// to create a stream. How are we claiming that this RME has been deleted?
// We should throw some sort of Exception.
SIErrorException e =
new SIErrorException(
nls.getFormattedMessage(
"INTERNAL_MESSAGING_ERROR_CWSIP0001",
new Object[] {
"com.ibm.ws.sib.processor.impl.AnycastOutputHandler",
"1:3159:1.89.4.1" },
null));
FFDCFilter.processException(
e,
"com.ibm.ws.sib.processor.impl.AnycastOutputHandler.forceFlushAtSource",
"1:3165:1.89.4.1",
this);
SibTr.exception(tc, e);
SibTr.error(tc, "INTERNAL_MESSAGING_ERROR_CWSIP0001",
new Object[] {
"com.ibm.ws.sib.processor.impl.AnycastOutputHandler",
"1:3171:1.89.4.1" });
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
SibTr.exit(tc, "forceFlushAtSource");
throw e;
}
else
{
try
{
AOStream stream = sinfo.stream;
// first close() the stream.
stream.close();
// We are now guaranteed that all asynchronous writed to the Message Store initiated by that stream are done.
// Now get all the value ticks from the itemStream
ArrayList<AOValue> valueTicks = new ArrayList<AOValue>();
NonLockingCursor cursor = sinfo.itemStream.newNonLockingItemCursor(null);
AOValue tick;
while ((tick = (AOValue) cursor.next()) != null)
{
valueTicks.add(tick);
}
cursor.finished();
// now delete them and the item stream etc.
deleteAndUnlockPersistentStream(sinfo, valueTicks);
// now remove from the streamTable
synchronized (streamTable)
{
streamTable.remove(key);
}
success = true;
}
catch (Exception e)
{
FFDCFilter.processException(
e,
"com.ibm.ws.sib.processor.impl.AnycastOutputHandler.forceFlushAtSource",
"1:3211:1.89.4.1",
this);
SibTr.exception(tc, e);
SibTr.error(tc, "INTERNAL_MESSAGING_ERROR_CWSIP0001",
new Object[] {
"com.ibm.ws.sib.processor.impl.AnycastOutputHandler",
"1:3217:1.89.4.1" });
// we should throw an exception
SIErrorException e2 =
new SIErrorException(
nls.getFormattedMessage(
"INTERNAL_MESSAGING_ERROR_CWSIP0001",
new Object[] {
"com.ibm.ws.sib.processor.impl.AnycastOutputHandler",
"1:3226:1.89.4.1"},
null));
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
SibTr.exit(tc, "forceFlushAtSource");
throw e2;
}
} // end else
if (success)
{
// Log message to console saying we have finished flush at anycast DME for this destination and RME
SibTr.info(
tc,
"FLUSH_COMPLETE_CWSIP0452",
new Object[] {destName,
mp.getMessagingEngineName(),
key});
}
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
SibTr.exit(tc, "forceFlushAtSource");
}
|
java
|
private void deleteAndUnlockPersistentStream(StreamInfo sinfo, ArrayList valueTicks) throws MessageStoreException, SIRollbackException, SIConnectionLostException, SIIncorrectCallException, SIResourceException, SIErrorException
{
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
SibTr.entry(tc, "deleteAndUnlockPersistentStream", new Object[]{sinfo, valueTicks});
// create a transaction, and delete all AOValue ticks, unlock the persistent locks,
// and then remove sinfo.itemStream, and sinfo.item
LocalTransaction tran = getLocalTransaction();
cleanupTicks(sinfo, tran, valueTicks);
Transaction msTran = mp.resolveAndEnlistMsgStoreTransaction(tran);
sinfo.itemStream.lockItemIfAvailable(controlItemLockID); // will always be available
sinfo.itemStream.remove(msTran, controlItemLockID);
if (sinfo.item != null)
{
sinfo.item.lockItemIfAvailable(controlItemLockID); // will always be available
sinfo.item.remove(msTran, controlItemLockID);
}
tran.commit();
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(tc, "deleteAndUnlockPersistentStream");
}
|
java
|
protected void init(boolean useDirect, int outSize, int inSize, int cacheSize) {
this.useDirectBuffer = useDirect;
this.outgoingHdrBufferSize = outSize;
this.incomingBufferSize = inSize;
// if cache size has increased, then allocate the larger bytecache
// array, but don't change to a smaller array
if (cacheSize > this.byteCacheSize) {
this.byteCacheSize = cacheSize;
this.byteCache = new byte[cacheSize];
}
}
|
java
|
public void addParseBuffer(WsByteBuffer buffer) {
// increment where we're about to put the new buffer in
int index = ++this.parseIndex;
if (null == this.parseBuffers) {
// first parse buffer to track
this.parseBuffers = new WsByteBuffer[BUFFERS_INITIAL_SIZE];
this.parseBuffersStartPos = new int[BUFFERS_INITIAL_SIZE];
for (int i = 0; i < BUFFERS_INITIAL_SIZE; i++) {
this.parseBuffersStartPos[i] = HeaderStorage.NOTSET;
}
} else if (index == this.parseBuffers.length) {
// grow the array
int size = index + BUFFERS_MIN_GROWTH;
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
Tr.debug(tc, "Increasing parse buffer array size to " + size);
}
WsByteBuffer[] tempNew = new WsByteBuffer[size];
System.arraycopy(this.parseBuffers, 0, tempNew, 0, index);
this.parseBuffers = tempNew;
int[] posNew = new int[size];
System.arraycopy(this.parseBuffersStartPos, 0, posNew, 0, index);
for (int i = index; i < size; i++) {
posNew[i] = HeaderStorage.NOTSET;
}
this.parseBuffersStartPos = posNew;
}
this.parseBuffers[index] = buffer;
}
|
java
|
public void addToCreatedBuffer(WsByteBuffer buffer) {
// increment where we're about to put the new buffer in
int index = ++this.createdIndex;
if (null == this.myCreatedBuffers) {
// first allocation
this.myCreatedBuffers = new WsByteBuffer[BUFFERS_INITIAL_SIZE];
} else if (index == this.myCreatedBuffers.length) {
// grow the array
int size = index + BUFFERS_MIN_GROWTH;
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
Tr.debug(tc, "Increasing created buffer array size to " + size);
}
WsByteBuffer[] tempNew = new WsByteBuffer[size];
System.arraycopy(this.myCreatedBuffers, 0, tempNew, 0, index);
this.myCreatedBuffers = tempNew;
}
this.myCreatedBuffers[index] = buffer;
}
|
java
|
public void clear() {
final boolean bTrace = TraceComponent.isAnyTracingEnabled();
if (bTrace && tc.isEntryEnabled()) {
Tr.entry(tc, "clear");
}
clearAllHeaders();
this.eohPosition = HeaderStorage.NOTSET;
this.currentElem = null;
this.stateOfParsing = PARSING_CRLF;
this.binaryParsingState = GenericConstants.PARSING_HDR_FLAG;
this.parsedToken = null;
this.parsedTokenLength = 0;
this.bytePosition = 0;
this.byteLimit = 0;
this.currentReadBB = null;
clearBuffers();
this.debugContext = this;
this.numCRLFs = 0;
this.bIsMultiLine = false;
this.lastCRLFBufferIndex = HeaderStorage.NOTSET;
this.lastCRLFPosition = HeaderStorage.NOTSET;
this.lastCRLFisCR = false;
this.headerChangeCount = 0;
this.headerAddCount = 0;
this.bOverChangeLimit = false;
this.compactHeaderFlag = false;
this.table = null;
this.isPushPromise = false;
this.processedXForwardedHeader = false;
this.processedForwardedHeader = false;
this.forwardHeaderErrorState = false;
this.forwardedByList = null;
this.forwardedForList = null;
this.forwardedHost = null;
this.forwardedPort = null;
this.forwardedProto = null;
if (bTrace && tc.isEntryEnabled()) {
Tr.exit(tc, "clear");
}
}
|
java
|
private void clearBuffers() {
// simply null out the parse buffers list, then release all the created buffers
final boolean bTrace = TraceComponent.isAnyTracingEnabled();
for (int i = 0; i <= this.parseIndex; i++) {
if (bTrace && tc.isDebugEnabled()) {
Tr.debug(tc, "Removing reference to parse buffer: " + this.parseBuffers[i]);
}
this.parseBuffers[i] = null;
this.parseBuffersStartPos[i] = HeaderStorage.NOTSET;
}
this.parseIndex = HeaderStorage.NOTSET;
for (int i = 0; i <= this.createdIndex; i++) {
if (bTrace && tc.isDebugEnabled()) {
Tr.debug(tc, "Releasing marshall buffer: " + this.myCreatedBuffers[i]);
}
this.myCreatedBuffers[i].release();
this.myCreatedBuffers[i] = null;
}
this.createdIndex = HeaderStorage.NOTSET;
}
|
java
|
public void debug() {
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
Tr.debug(tc, "*** Begin Header Debug ***");
HeaderElement elem = this.hdrSequence;
while (null != elem) {
Tr.debug(tc, elem.getName() + ": " + elem.getDebugValue());
elem = elem.nextSequence;
}
Tr.debug(tc, "*** End Header Debug ***");
}
}
|
java
|
protected void destroy() {
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
Tr.debug(tc, "Destroying these headers: " + this);
}
// if we have headers present, or reference parse buffers (i.e.
// the first header parsed threw an error perhaps), then clear
// the message now
if (null != this.hdrSequence || HeaderStorage.NOTSET != this.parseIndex) {
clear();
}
this.byteCacheSize = DEFAULT_CACHESIZE;
this.incomingBufferSize = DEFAULT_BUFFERSIZE;
this.outgoingHdrBufferSize = DEFAULT_BUFFERSIZE;
this.useDirectBuffer = true;
this.limitNumHeaders = DEFAULT_LIMIT_NUMHEADERS;
this.limitTokenSize = DEFAULT_LIMIT_TOKENSIZE;
this.headerChangeLimit = HeaderStorage.NOTSET;
}
|
java
|
protected void writeByteArray(ObjectOutput output, byte[] data) throws IOException {
if (null == data || 0 == data.length) {
output.writeInt(-1);
} else {
output.writeInt(data.length);
output.write(data);
}
}
|
java
|
private void scribbleWhiteSpace(WsByteBuffer buffer, int start, int stop) {
if (buffer.hasArray()) {
// buffer has a backing array so directly update that
final byte[] data = buffer.array();
final int offset = buffer.arrayOffset();
int myStart = start + offset;
int myStop = stop + offset;
for (int i = myStart; i < myStop; i++) {
data[i] = BNFHeaders.SPACE;
}
} else {
// overlay whitespace into the buffer
byte[] localWhitespace = whitespace;
if (null == localWhitespace) {
localWhitespace = getWhiteSpace();
}
buffer.position(start);
int len = stop - start;
while (len > 0) {
if (localWhitespace.length >= len) {
buffer.put(localWhitespace, 0, len);
break; // out of while
}
int partial = localWhitespace.length;
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
Tr.debug(tc, "Scribbling " + partial + " bytes of whitespace");
}
buffer.put(localWhitespace, 0, partial);
len -= partial;
}
}
}
|
java
|
private void eraseValue(HeaderElement elem) {
// wipe out the removed value
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
Tr.debug(tc, "Erasing existing header: " + elem.getName());
}
int next_index = this.lastCRLFBufferIndex;
int next_pos = this.lastCRLFPosition;
if (null != elem.nextSequence && !elem.nextSequence.wasAdded()) {
next_index = elem.nextSequence.getLastCRLFBufferIndex();
next_pos = elem.nextSequence.getLastCRLFPosition();
}
int start = elem.getLastCRLFPosition();
// if it's only in one buffer, this for loop does nothing
for (int x = elem.getLastCRLFBufferIndex(); x < next_index; x++) {
// wiping out this buffer from start to limit
this.parseBuffers[x].position(start);
this.parseBuffers[x].limit(start);
start = 0;
}
// last buffer, scribble from start until next_pos
scribbleWhiteSpace(this.parseBuffers[next_index], start, next_pos);
}
|
java
|
private int overlayBytes(byte[] data, int inOffset, int inLength, int inIndex) {
int length = inLength;
int offset = inOffset;
int index = inIndex;
WsByteBuffer buffer = this.parseBuffers[index];
if (-1 == length) {
length = data.length;
}
while (index <= this.parseIndex) {
int remaining = buffer.remaining();
if (remaining >= length) {
// it all fits now
buffer.put(data, offset, length);
return index;
}
// put what we can, loop through the next buffer
buffer.put(data, offset, remaining);
offset += remaining;
length -= remaining;
buffer = this.parseBuffers[++index];
buffer.position(0);
}
return index;
}
|
java
|
private void overlayValue(HeaderElement elem) {
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
Tr.debug(tc, "Overlaying existing header: " + elem.getName());
}
int next_index = this.lastCRLFBufferIndex;
int next_pos = this.lastCRLFPosition;
if (null != elem.nextSequence && !elem.nextSequence.wasAdded()) {
next_index = elem.nextSequence.getLastCRLFBufferIndex();
next_pos = elem.nextSequence.getLastCRLFPosition();
}
WsByteBuffer buffer = this.parseBuffers[elem.getLastCRLFBufferIndex()];
buffer.position(elem.getLastCRLFPosition() + (elem.isLastCRLFaCR() ? 2 : 1));
if (next_index == elem.getLastCRLFBufferIndex()) {
// all in one buffer
buffer.put(elem.getKey().getMarshalledByteArray(foundCompactHeader()));
buffer.put(elem.asRawBytes(), elem.getOffset(), elem.getValueLength());
} else {
// header straddles buffers
int index = elem.getLastCRLFBufferIndex();
index = overlayBytes(elem.getKey().getMarshalledByteArray(foundCompactHeader()), 0, -1, index);
index = overlayBytes(elem.asRawBytes(), elem.getOffset(), elem.getValueLength(), index);
buffer = this.parseBuffers[index];
}
// pad trailing whitespace if we need it
int start = buffer.position();
if (start < next_pos) {
scribbleWhiteSpace(buffer, start, next_pos);
}
}
|
java
|
private WsByteBuffer[] marshallAddedHeaders(WsByteBuffer[] inBuffers, int index) {
WsByteBuffer[] buffers = inBuffers;
buffers[index] = allocateBuffer(this.outgoingHdrBufferSize);
for (HeaderElement elem = this.hdrSequence; null != elem; elem = elem.nextSequence) {
if (elem.wasAdded()) {
buffers = marshallHeader(buffers, elem);
}
}
// add second EOL
buffers = putBytes(BNFHeaders.EOL, buffers);
buffers = flushCache(buffers);
// flip the last buffer now that we're done
buffers[buffers.length - 1].flip();
return buffers;
}
|
java
|
private void clearAllHeaders() {
final boolean bTrace = TraceComponent.isAnyTracingEnabled();
if (bTrace && tc.isEntryEnabled()) {
Tr.entry(tc, "clearAllHeaders()");
}
HeaderElement elem = this.hdrSequence;
while (null != elem) {
final HeaderElement next = elem.nextSequence;
final HeaderKeys key = elem.getKey();
final int ord = key.getOrdinal();
if (storage.containsKey(ord)) {
// first instance being removed
if (key.useFilters()) {
filterRemove(key, null);
}
storage.remove(ord);
}
elem.destroy();
elem = next;
}
this.hdrSequence = null;
this.lastHdrInSequence = null;
this.numberOfHeaders = 0;
if (bTrace && tc.isEntryEnabled()) {
Tr.exit(tc, "clearAllHeaders()");
}
}
|
java
|
public void removeSpecialHeader(HeaderKeys key) {
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
Tr.debug(tc, "removeSpecialHeader(h): " + key.getName());
}
removeHdrInstances(findHeader(key), FILTER_NO);
}
|
java
|
public WsByteBuffer returnCurrentBuffer() {
WsByteBuffer buff = null;
if (HeaderStorage.NOTSET != this.parseIndex) {
buff = this.parseBuffers[this.parseIndex];
this.parseIndex--;
}
return buff;
}
|
java
|
private void createSingleHeader(HeaderKeys key, byte[] value, int offset, int length) {
HeaderElement elem = findHeader(key);
if (null != elem) {
// delete all secondary instances first
if (null != elem.nextInstance) {
HeaderElement temp = elem.nextInstance;
while (null != temp) {
temp.remove();
temp = temp.nextInstance;
}
}
if (HeaderStorage.NOTSET != this.headerChangeLimit) {
// parse buffer reuse is enabled, see if we can use existing obj
if (length <= elem.getValueLength()) {
this.headerChangeCount++;
elem.setByteArrayValue(value, offset, length);
} else {
elem.remove();
elem = null;
}
} else {
// parse buffer reuse is disabled
elem.setByteArrayValue(value, offset, length);
}
}
if (null == elem) {
// either it didn't exist or we chose not to re-use the object
elem = getElement(key);
elem.setByteArrayValue(value, offset, length);
addHeader(elem, FILTER_NO);
} else if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
Tr.debug(tc, "Replacing header " + key.getName() + " [" + elem.getDebugValue() + "]");
}
}
|
java
|
private void addHeader(HeaderElement elem, boolean bFilter) {
final HeaderKeys key = elem.getKey();
if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled()) {
Tr.event(tc, "Adding header [" + key.getName()
+ "] with value [" + elem.getDebugValue() + "]");
}
if (getRemoteIp() && key.getName().toLowerCase().startsWith("x-forwarded") && !forwardHeaderErrorState) {
processForwardedHeader(elem, true);
}
else if (getRemoteIp() && key.getName().toLowerCase().startsWith("forwarded") && !forwardHeaderErrorState) {
processForwardedHeader(elem, false);
}
if (bFilter) {
if (key.useFilters() && !filterAdd(key, elem.asBytes())) {
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
Tr.debug(tc, "filter disallowed: " + elem.getDebugValue());
}
return;
}
}
if (HttpHeaderKeys.isWasPrivateHeader(key.getName())) {
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
Tr.debug(tc, "checking to see if private header is allowed: " + key.getName());
}
if (!filterAdd(key, elem.asBytes())) {
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
Tr.debug(tc, key.getName() +" is not trusted for this host; not adding header");
}
return;
}
}
incrementHeaderCounter();
HeaderElement root = findHeader(key);
boolean rc = addInstanceOfElement(root, elem);
// did we change the root node?
if (rc) {
final int ord = key.getOrdinal();
storage.put(ord, elem);
}
}
|
java
|
private HeaderElement findHeader(HeaderKeys key, int instance) {
final int ord = key.getOrdinal();
if (!storage.containsKey(ord) && ord <= HttpHeaderKeys.ORD_MAX) {
return null;
}
HeaderElement elem = null;
//If the ordinal created for this key is larger than 1024, the header key
//storage has been capped. As such, search the internal header storage
//to see if we have a header with this name already added.
if (ord > HttpHeaderKeys.ORD_MAX) {
for (HeaderElement header : storage.values()) {
if (header.getKey().getName().equals(key.getName())) {
elem = header;
break;
}
}
} else {
elem = storage.get(ord);
}
int i = -1;
while (null != elem) {
if (!elem.wasRemoved()) {
if (++i == instance) {
return elem;
}
}
elem = elem.nextInstance;
}
return null;
}
|
java
|
private void removeHdr(HeaderElement elem) {
if (null == elem) {
return;
}
HeaderKeys key = elem.getKey();
elem.remove();
if (key.useFilters()) {
filterRemove(key, elem.asBytes());
}
}
|
java
|
private void removeHdrInstances(HeaderElement root, boolean bFilter) {
if (null == root) {
return;
}
HeaderKeys key = root.getKey();
if (bFilter && key.useFilters()) {
filterRemove(key, null);
}
HeaderElement elem = root;
while (null != elem) {
elem.remove();
elem = elem.nextInstance;
}
}
|
java
|
protected void setSpecialHeader(HeaderKeys key, byte[] value) {
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
Tr.debug(tc, "setSpecialHeader(h,b[]): " + key.getName());
}
removeHdrInstances(findHeader(key), FILTER_NO);
HeaderElement elem = getElement(key);
elem.setByteArrayValue(value);
addHeader(elem, FILTER_NO);
}
|
java
|
public void setHeaderChangeLimit(int limit) {
this.headerChangeLimit = limit;
this.bOverChangeLimit = false;
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
Tr.debug(tc, "Setting header change limit to " + limit);
}
}
|
java
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.