code
stringlengths
73
34.1k
label
stringclasses
1 value
public Runnable execute(Runnable command, long timeoutInMillis) throws InterruptedException, IllegalStateException { try { return execute(command, WAIT_WHEN_QUEUE_IS_FULL, timeoutInMillis); } catch (ThreadPoolQueueIsFullException e) { // we should not get here. // Alex Ffdc.log(e, this, ThreadPool.class.getName(), "855"); // D477704.2 return null; } }
java
public void setMonitorPlugin(MonitorPlugin plugin) throws TooManyListenersException { if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) { Tr.entry(tc, "setMonitorPlugin", plugin); } if (this.monitorPlugin != null && !this.monitorPlugin.equals(plugin)) { throw new TooManyListenersException("INTERNAL ERROR: ThreadPool.MonitorPlugin already set."); } this.monitorPlugin = plugin; if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) { Tr.exit(tc, "setMonitorPlugin", plugin); } }
java
public void checkAllThreads() { // if nothing is plugged in, exit early if (this.monitorPlugin == null) { return; } long currentTime = 0; // lazily initialize current time try { for (Iterator i = this.threads_.values().iterator(); i.hasNext();) { Worker thread = (Worker) i.next(); synchronized (thread) { // d204471 if (thread.getStartTime() > 0) { if (currentTime == 0) { currentTime = System.currentTimeMillis(); } if (!thread.isHung && this.monitorPlugin.checkThread(thread, thread.threadNumber, currentTime - thread.getStartTime())) { // PK25446 thread.isHung = true; } } } } this.lastThreadCheckDidntComplete = false; // D222794 } catch (ConcurrentModificationException e) { // begin D222794 // NOTE: we can pretty much ignore this exception ... if // we occasionally fail on the check, we'll be OK. So // we simply keep track with a flag. If two consecutive // checks fail, then we'll log to FFDC if (this.lastThreadCheckDidntComplete) { // Alex Ffdc.log(e, this, this.getClass().getName(), "1181", this); // // D477704.2 } this.lastThreadCheckDidntComplete = true; } // end D222794 }
java
public FilterCellSlowStr findNextCell(String nextValue) { if (nextCell == null) { return null; } return nextCell.get(nextValue); }
java
protected boolean invokeGeneratePluginCfgMBean(ParseLoginAddress loginAddress, String clusterName, String targetPath, String option) { boolean success = false; try { success = connection.generatePluginConfig(loginAddress, clusterName, targetPath ,option); if (success) success = copyFileToTargetPath(loginAddress,clusterName,targetPath); if(success){ if(option.equalsIgnoreCase("server")){ commandConsole.printlnInfoMessage(getMessage("generateWebServerPluginTask.complete.server")); } else commandConsole.printlnInfoMessage(getMessage("generateWebServerPluginTask.complete.collective")); } else if(option.equalsIgnoreCase("server")){ commandConsole.printlnInfoMessage(getMessage("generateWebServerPluginTask.fail.server")); } else commandConsole.printlnInfoMessage(getMessage("generateWebServerPluginTask.fail.collective")); } catch (RuntimeMBeanException e) { commandConsole.printlnErrorMessage(getMessage("common.connectionError", e.getMessage())); } catch (UnknownHostException e) { // java.net.UnknownHostException: bad host commandConsole.printlnErrorMessage(getMessage("common.hostError", loginAddress.getHost())); } catch (ConnectException e) { // java.net.ConnectException: bad port commandConsole.printlnErrorMessage(getMessage("common.portError", loginAddress.getPort())); } catch (IOException e) { // java.io.IOException: bad creds or some other IO error commandConsole.printlnErrorMessage(getMessage("common.connectionError", e.getMessage())); } catch (Exception e) { String msg = e.getMessage(); if (msg != null) { //int idx = e.getMessage().indexOf(MBEAN_NOT_PRESENT_MSG_ID); //if (idx > -1) { commandConsole.printlnInfoMessage(getMessage("generateWebServerPluginTask.notEnabled")); //} } commandConsole.printlnErrorMessage(getMessage("common.connectionError", e.getMessage())); } finally { try { connection.closeConnector(); } catch (IOException e) { // java.io.IOException: some other IO error commandConsole.printlnErrorMessage(getMessage("common.connectionError", e.getMessage())); } } return success; }
java
public static TraceFactory getTraceFactory(NLS nls) { return (TraceFactory) Utils.getImpl("com.ibm.ws.objectManager.utils.TraceFactoryImpl", new Class[] { NLS.class }, new Object[] { nls }); }
java
public void setActiveTrace(String activeNames, int traceLevel) throws java.io.IOException { TraceFactory.activeNames = activeNames; TraceFactory.traceLevel = traceLevel;; }
java
protected void setSICoreConnection(SICoreConnection connection) { if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(this, tc, "setSICoreConnection", connection); //Retrieve Client Conversation State if necessary validateConversationState(); cConState.setSICoreConnection(connection); if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(this, tc, "setSICoreConnection"); }
java
public Serializable copy(Serializable obj) { final boolean isTraceOn = TraceComponent.isAnyTracingEnabled(); if (isTraceOn && tc.isDebugEnabled()) Tr.debug(tc, "copy : " + Util.identity(obj)); // ----------------------------------------------------------------------- // Optimize copyObject by special casing null, immutable objects, // and primitive arrays. All of these can be handled much more // efficiently than performing a 'deep' copy. d154342.7 // ----------------------------------------------------------------------- if (obj == null) { return obj; } Class<?> objType = obj.getClass(); // if the object is a primitive wrapper class, then return it. if ((objType == String.class) || (objType == Integer.class) || (objType == Long.class) || (objType == Boolean.class) || (objType == Byte.class) || (objType == Character.class) || (objType == Float.class) || (objType == Double.class) || (objType == Short.class)) { // Yes, so do nothing... return obj; } Class<?> componentType = objType.getComponentType(); // If this is an array of primitives take a clone instead of deep copy if (componentType != null && componentType.isPrimitive()) { if (componentType == boolean.class) return ((boolean[]) obj).clone(); if (componentType == byte.class) return ((byte[]) obj).clone(); if (componentType == char.class) return ((char[]) obj).clone(); if (componentType == short.class) return ((short[]) obj).clone(); if (componentType == int.class) return ((int[]) obj).clone(); if (componentType == long.class) return ((long[]) obj).clone(); if (componentType == float.class) return ((float[]) obj).clone(); if (componentType == double.class) return ((double[]) obj).clone(); } // End d154342.7 if (isTraceOn && tc.isDebugEnabled()) Tr.debug(tc, "copy : making a deep copy"); return copySerializable(obj); }
java
public ScheduleExpression copy(ScheduleExpression schedule) { if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) Tr.debug(tc, "copy ScheduleExpression: " + Util.identity(schedule)); // 'schedule' could be a subclass of ScheduleExpression, so only // use the base class constructor if not a subclass. F743-21028.3 if (schedule.getClass() == ScheduleExpression.class) { return copyBase(schedule); // 632906 } return (ScheduleExpression) copySerializable(schedule); }
java
public static ScheduleExpression copyBase(ScheduleExpression schedule) // d632906 { if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) Tr.debug(tc, "copy copyBase: " + Util.identity(schedule)); // 'schedule' could be a subclass of ScheduleExpression. // Use only the base class constructor. return new ScheduleExpression() .start(schedule.getStart() == null ? null : new Date(schedule.getStart().getTime())) .end(schedule.getEnd() == null ? null : new Date(schedule.getEnd().getTime())) .timezone(schedule.getTimezone()) .second(schedule.getSecond()) .minute(schedule.getMinute()) .hour(schedule.getHour()) .dayOfMonth(schedule.getDayOfMonth()) .dayOfWeek(schedule.getDayOfWeek()) .month(schedule.getMonth()) .year(schedule.getYear()); }
java
BigInteger setMultiChoiceCount() { if (fields != null) for (int i = 0; i < fields.length; i++) multiChoiceCount = multiChoiceCount.multiply(fields[i].setMultiChoiceCount()); return multiChoiceCount; }
java
public JSVariant[] getDominatedVariants() { if (dominated == null) { List dom = new ArrayList(); getDominatedVariants(dom); dominated = (JSVariant[])dom.toArray(new JSVariant[0]); } return dominated; }
java
public static ChainStartMode getKey(int ordinal) { if (ordinal >= 0 && ordinal < _values.length) { return _values[ordinal]; } return null; }
java
public static InjectionTarget getInjectionTarget(ComponentNameSpaceConfiguration compNSConfig, ClientInjection injection) throws InjectionException { final boolean isTraceOn = TraceComponent.isAnyTracingEnabled(); if (isTraceOn && tc.isEntryEnabled()) Tr.entry(tc, "getInjectionTarget: " + injection); // Create a temporary InjectionBinding in order to resolve the target. ClientInjectionBinding binding = new ClientInjectionBinding(compNSConfig, injection); Class<?> injectionType = binding.loadClass(injection.getInjectionTypeName()); String targetName = injection.getTargetName(); String targetClassName = injection.getTargetClassName(); // Add a single injection target and then retrieve it. binding.addInjectionTarget(injectionType, targetName, targetClassName); InjectionTarget target = InjectionProcessorContextImpl.getInjectionTargets(binding).get(0); binding.metadataProcessingComplete(); // d681767 if (isTraceOn && tc.isEntryEnabled()) Tr.exit(tc, "getInjectionTarget: " + target); return target; }
java
protected ArrayList filterXidsByType(Xid[] xidArray) { if (tc.isEntryEnabled()) Tr.entry(tc, "filterXidsByType", xidArray); final ArrayList<XidImpl> xidList = new ArrayList<XidImpl>(); if (xidArray != null) { /*----------------------------------------------------------*/ /* Iterate over the list of returned xids, and insert them */ /* into a new list containing all the xids that have been */ /* recovered thus far. We don't have to worry about */ /* duplicates because every resource is guaranteed to have a */ /* unique bqual + gtrid combination. */ /*----------------------------------------------------------*/ for (int y = 0; y < xidArray.length; y++) { // PQ56777 - Oracle can return entries with null in them. // normally(?) it will be the last in the list. It // appears to happen if an indoubt transaction on the // database completes during our call to recover. if (xidArray[y] == null) { if (tc.isDebugEnabled()) Tr.debug(tc, "RM has returned null inDoubt Xid entry - " + y); continue; } /*------------------------------------------------------*/ /* We only want to add this Xid to our list if it is */ /* one that we generated. */ /*------------------------------------------------------*/ if (XidImpl.isOurFormatId(xidArray[y].getFormatId())) { /*--------------------------------------------------*/ /* It is possible that the Xid we get back from the */ /* RM is actually an instance of our XidImpl. In */ /* the case that it's not, we have to re-construct */ /* the XidImpl so that we can extract the xid bytes. */ /*--------------------------------------------------*/ XidImpl ourXid = null; if (xidArray[y] instanceof XidImpl) { ourXid = (XidImpl) xidArray[y]; } else { ourXid = new XidImpl(xidArray[y]); // Check the bqual is one of ours... // as V5.1 also uses the same formatId but with // different length encoding if (ourXid.getBranchQualifier().length != XidImpl.BQUAL_JTA_BQUAL_LENGTH) { if (tc.isDebugEnabled()) Tr.debug(tc, "Xid is wrong length - " + y); continue; } } xidList.add(ourXid); } /* if isOurFormatId() */ } /* for each Xid */ } /* if xidArray != null */ if (tc.isEntryEnabled()) Tr.exit(tc, "filterXidsByType", xidList); return xidList; }
java
protected ArrayList filterXidsByCruuidAndEpoch(ArrayList xidList, byte[] cruuid, int epoch) { if (tc.isEntryEnabled()) Tr.entry(tc, "filterXidsByCruuidAndEpoch", new Object[] { xidList, cruuid, epoch }); for (int x = xidList.size() - 1; x >= 0; x--) { final XidImpl ourXid = (XidImpl) xidList.get(x); final byte[] xidCruuid = ourXid.getCruuid(); final int xidEpoch = ourXid.getEpoch(); if (tc.isDebugEnabled()) { Tr.debug(tc, "Trace other Cruuid: " + xidCruuid + ", or: " + Util.toHexString(xidCruuid)); Tr.debug(tc, "Trace my Cruuid: " + cruuid + ", or: " + Util.toHexString(cruuid)); } if ((!java.util.Arrays.equals(cruuid, xidCruuid))) { if (tc.isDebugEnabled()) Tr.debug(tc, "filterXidsByCruuidAndEpoch: cruuid is different: " + ourXid.getCruuid()); xidList.remove(x); } else if (xidEpoch >= epoch) { if (tc.isDebugEnabled()) Tr.debug(tc, "filterXidsByCruuidAndEpoch: xid epoch is " + xidEpoch); xidList.remove(x); } } if (tc.isEntryEnabled()) Tr.exit(tc, "filterXidsByCruuidAndEpoch", xidList); return xidList; }
java
protected boolean canWeForgetXid(XidImpl ourXid, Xid[] knownXids) { if (tc.isEntryEnabled()) Tr.entry(tc, "canWeForgetXid", new Object[] { ourXid, knownXids }); if (tc.isDebugEnabled()) { // We are only called if knownXids != null for (int i = 0; i < knownXids.length; i++) { Tr.debug(tc, "tx xid[" + i + "] " + knownXids[i]); } } boolean forgetMe = true; /*----------------------------------------------------------------*/ /* Yank the parts of the JTA xid. The branch qualifier will be */ /* the full JTA branch qualifier, and will need to be shortened */ /* to the same length of the transaction bqual so that the array */ /* compare has a chance to complete successfully. */ /*----------------------------------------------------------------*/ final int jtaFormatId = ourXid.getFormatId(); final byte[] jtaGtrid = ourXid.getGlobalTransactionId(); final byte[] fullJtaBqual = ourXid.getBranchQualifier(); byte[] jtaBqual = null; /*----------------------------------------------------------------*/ /* We have to separate the transaction gtrid and bqual for the */ /* array compares. These are places to store these items. */ /*----------------------------------------------------------------*/ int txnFormatId; byte[] txnGtrid; byte[] txnBqual; /*----------------------------------------------------------------*/ /* Iterate over all the known XIDs (if there are none, we won't */ /* iterate over anything). */ /*----------------------------------------------------------------*/ int x = 0; while ((x < knownXids.length) && (forgetMe == true)) { /*------------------------------------------------------------*/ /* If this is the first XID, shorten the JTA bqual to the */ /* length of the transaction bqual. We are assuming here */ /* that all the transaction bquals are the same length. If */ /* they arent, for some reason, we will need to revisit this. */ /*------------------------------------------------------------*/ if (x == 0) { final int bqualLength = (knownXids[x].getBranchQualifier()).length; jtaBqual = new byte[bqualLength]; System.arraycopy(fullJtaBqual, 0, jtaBqual, 0, bqualLength); } /*------------------------------------------------------------*/ /* Separate the transaction XID into comparable units. */ /*------------------------------------------------------------*/ txnFormatId = knownXids[x].getFormatId(); txnGtrid = knownXids[x].getGlobalTransactionId(); txnBqual = knownXids[x].getBranchQualifier(); /*------------------------------------------------------------*/ /* Compare the individual parts of the XID for equality. If */ /* they are equal, set a boolean value and we can stop */ /* checking. */ /*------------------------------------------------------------*/ if ((jtaFormatId == txnFormatId) && (java.util.Arrays.equals(jtaGtrid, txnGtrid)) && (java.util.Arrays.equals(jtaBqual, txnBqual))) { if (tc.isDebugEnabled()) { Tr.debug(tc, "Xid has been matched to a transaction:", ourXid); } auditTransactionXid(ourXid, knownXids[x], getXAResourceInfo()); forgetMe = false; } x++; } if (tc.isEntryEnabled()) Tr.exit(tc, "canWeForgetXid", forgetMe); return forgetMe; }
java
private static void propogateSecureSession(HttpServletRequest request, Message message) { final String cipherSuite = (String) request.getAttribute(SSL_CIPHER_SUITE_ATTRIBUTE); if (cipherSuite != null) { final java.security.cert.Certificate[] certs = (java.security.cert.Certificate[]) request.getAttribute(SSL_PEER_CERT_CHAIN_ATTRIBUTE); message.put(TLSSessionInfo.class, new TLSSessionInfo(cipherSuite, null, certs)); } }
java
private void cacheInput(Message outMessage) { if (outMessage.getExchange() == null) { return; } Message inMessage = outMessage.getExchange().getInMessage(); if (inMessage == null) { return; } Object o = inMessage.get("cxf.io.cacheinput"); DelegatingInputStream in = inMessage.getContent(DelegatingInputStream.class); if (PropertyUtils.isTrue(o)) { Collection<Attachment> atts = inMessage.getAttachments(); if (atts != null) { for (Attachment a : atts) { if (a.getDataHandler().getDataSource() instanceof AttachmentDataSource) { try { ((AttachmentDataSource) a.getDataHandler().getDataSource()).cache(inMessage); } catch (IOException e) { throw new Fault(e); } } } } if (in != null) { in.cacheInput(); } } else if (in != null) { //We don't need to cache it, but we may need to consume it in order for the client // to be able to receive a response. (could be blocked sending) //However, also don't want to consume indefinitely. We'll limit to 16M. try { IOUtils.consume(in, 16 * 1024 * 1024); } catch (Exception ioe) { //ignore } } }
java
public static void processException(Object source ,Class sourceClass ,String methodName ,Throwable throwable ,String probe ,Object[] objects ) { if (TraceComponent.isAnyTracingEnabled() && trace.isEntryEnabled()) trace.entry(cclass ,"processException" ,new Object[]{source ,sourceClass ,methodName ,throwable ,probe ,objects } ); if (TraceComponent.isAnyTracingEnabled() && trace.isEventEnabled()) trace.event(cclass, "processException", throwable); print(source ,sourceClass ,methodName ,throwable ,probe ,objects); com.ibm.ws.ffdc.FFDCFilter.processException(throwable ,sourceClass.getName()+":"+methodName ,probe ,source ,objects); if (TraceComponent.isAnyTracingEnabled() && trace.isEntryEnabled()) trace.exit(cclass,"processException"); }
java
static void print(Object object,java.io.PrintWriter printWriter) { if (object instanceof Printable) { ((Printable)object).print(printWriter); } else { printWriter.print(object); } // if (object instanceof Printable). }
java
byte[] getServiceData() throws InternalLogException { if (tc.isEntryEnabled()) Tr.entry(tc, "getServiceData", this); // Check that the file is actually open if (_activeFile == null) { if (tc.isEntryEnabled()) Tr.exit(tc, "getServiceData", "InternalLogException"); throw new InternalLogException(null); } final byte[] serviceData = _activeFile.getServiceData(); if (tc.isEntryEnabled()) Tr.exit(tc, "getServiceData", RLSUtils.toHexString(serviceData, RLSUtils.MAX_DISPLAY_BYTES)); return serviceData; }
java
LogFileHeader logFileHeader() throws InternalLogException { if (tc.isEntryEnabled()) Tr.entry(tc, "logFileHeader", this); // Check that the file is actually open if (_activeFile == null) { if (tc.isEntryEnabled()) Tr.exit(tc, "logFileHeader", "InternalLogException"); throw new InternalLogException(null); } final LogFileHeader logFileHeader = _activeFile.logFileHeader(); if (tc.isEntryEnabled()) Tr.exit(tc, "logFileHeader", logFileHeader); return logFileHeader; }
java
ArrayList<ReadableLogRecord> recoveredRecords() { if (tc.isDebugEnabled()) Tr.debug(tc, "recoveredRecords", _recoveredRecords); return _recoveredRecords; }
java
void setServiceData(byte[] serviceData) throws InternalLogException { if (tc.isEntryEnabled()) Tr.entry(tc, "setServiceData", new java.lang.Object[] { RLSUtils.toHexString(serviceData, RLSUtils.MAX_DISPLAY_BYTES), this }); // Check that the files are available if ((_file1 == null) || (_file2 == null)) { if (tc.isEntryEnabled()) Tr.exit(tc, "setServiceData", "InternalLogException"); throw new InternalLogException(null); } // Cache the service data buffer reference. This class logically 'owns' the buffer. _serviceData = serviceData; // Pass the reference to the underlying log file objects. _file1.setServiceData(serviceData); _file2.setServiceData(serviceData); if (tc.isEntryEnabled()) Tr.exit(tc, "setServiceData"); }
java
protected void writeLogRecord(LogRecord logRecord) { if (tc.isEntryEnabled()) Tr.entry(tc, "writeLogRecord", logRecord); _activeFile.writeLogRecord(logRecord); if (tc.isEntryEnabled()) Tr.exit(tc, "writeLogRecord"); }
java
public static Map<String, String> processArchiveManifest(final JarFile jarFile) throws Throwable { Map<String, String> manifestAttrs = null; if (jarFile != null) { try { manifestAttrs = AccessController.doPrivileged(new PrivilegedExceptionAction<Map<String, String>>() { @Override public Map<String, String> run() throws ZipException, IOException { InputStream is = null; Map<String, String> attrs = null; try { // Read the manifest and access the manifest headers. is = jarFile.getInputStream(jarFile.getEntry(JarFile.MANIFEST_NAME)); attrs = ManifestProcessor.readManifestIntoMap(ManifestProcessor.parseManifest(is)); } finally { if (is != null) { InstallUtils.close(is); } } return attrs; } }); } catch (PrivilegedActionException e) { throw e.getCause(); } } return manifestAttrs; }
java
public static Map<String, String> processArchiveManifest(final File file) throws Throwable { Map<String, String> manifestAttrs = null; if (file != null && file.isFile() && ArchiveFileType.JAR.isType(file.getPath())) { JarFile jarFile = null; try { jarFile = new JarFile(file); manifestAttrs = processArchiveManifest(jarFile); } finally { if (jarFile != null) { InstallUtils.close(jarFile); } } } return manifestAttrs; }
java
public static String getLicenseAgreement(final JarFile jar, final Map<String, String> manifestAttrs) { String licenseAgreement = null; if (manifestAttrs.isEmpty()) { return licenseAgreement; } String licenseAgreementPrefix = manifestAttrs.get(ArchiveUtils.LICENSE_AGREEMENT); LicenseProvider licenseProvider = (licenseAgreementPrefix != null) ? ZipLicenseProvider.createInstance(jar, licenseAgreementPrefix) : null; if (licenseProvider != null) licenseAgreement = new InstallLicenseImpl("", LicenseType.UNSPECIFIED, licenseProvider).getAgreement(); return licenseAgreement; }
java
public void deactivate(ComponentContext context) { if (contextRef.get() == null) { // Components are only deactivated if they activate successfully, // and component instances are discarded after being deactivated. // This is either DS or programmer error. throw new IllegalStateException("not activated"); } this.contextRef.set(null); }
java
public void init(HttpInboundServiceContext sc) { // for requests, we don't care about the validation setHeaderValidation(false); setOwner(sc); setBinaryParseState(HttpInternalConstants.PARSING_BINARY_VERSION); }
java
public void init(HttpOutboundServiceContext sc) { // for requests, we don't care about the validation setHeaderValidation(false); setOwner(sc); setBinaryParseState(HttpInternalConstants.PARSING_BINARY_VERSION); setVersion(getServiceContext().getHttpConfig().getOutgoingVersion()); }
java
public void init(HttpInboundServiceContext sc, BNFHeaders hdrs) { // for requests, we don't care about the validation setHeaderValidation(false); setOwner(sc); setBinaryParseState(HttpInternalConstants.PARSING_BINARY_VERSION); if (null != hdrs) { hdrs.duplicate(this); } }
java
public void init(HttpOutboundServiceContext sc, BNFHeaders hdrs) { // for requests, we don't care about the validation setHeaderValidation(false); setOwner(sc); setBinaryParseState(HttpInternalConstants.PARSING_BINARY_VERSION); if (null != hdrs) { hdrs.duplicate(this); } setVersion(getServiceContext().getHttpConfig().getOutgoingVersion()); }
java
@Override public WsByteBuffer[] encodePseudoHeaders() { WsByteBuffer[] firstLine = new WsByteBuffer[1]; firstLine[0] = allocateBuffer(getOutgoingBufferSize()); LiteralIndexType indexType = LiteralIndexType.NOINDEXING; //For the time being, there will be no indexing on the responses to guarantee //the write context is concurrent to the remote endpoint's read context. Remote //intermediaries could index if they so desire, so setting NoIndexing (as //opposed to NeverIndexing). //TODO: investigate how streams and priority can work together with indexing on //responses. //LiteralIndexType indexType = isPushPromise ? LiteralIndexType.NOINDEXING : LiteralIndexType.INDEX; //Corresponding dynamic table H2HeaderTable table = this.getH2HeaderTable(); //Current encoded pseudo-header byte[] encodedHeader = null; try { //Encode the Method encodedHeader = H2Headers.encodeHeader(table, HpackConstants.METHOD, this.myMethod.toString(), indexType); firstLine = putBytes(encodedHeader, firstLine); //Encode Scheme encodedHeader = H2Headers.encodeHeader(table, HpackConstants.SCHEME, this.myScheme.toString(), indexType); this.myScheme.toString(); firstLine = putBytes(encodedHeader, firstLine); //Encode Authority if (this.sUrlHost != null) { // TODO: should the iUrlPort be added here? encodedHeader = H2Headers.encodeHeader(table, HpackConstants.AUTHORITY, this.sUrlHost, indexType); firstLine = putBytes(encodedHeader, firstLine); } //Encode Path encodedHeader = H2Headers.encodeHeader(table, HpackConstants.PATH, this.myURIString, indexType); firstLine = putBytes(encodedHeader, firstLine); } catch (Exception e) { if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled()) { Tr.error(tc, e.getMessage()); } return null; } // don't flip the last buffer as headers get tacked on the end if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled()) { String url = GenericUtils.nullOutPasswords(getMarshalledSecondToken(), (byte) '&'); Tr.event(tc, "Encoding first line: " + getMethod() + " " + url + " " + getVersion()); } return firstLine; }
java
@Override public void setMethod(String method) throws UnsupportedMethodException { MethodValues val = MethodValues.match(method, 0, method.length()); if (null == val) { throw new UnsupportedMethodException("Illegal method " + method); } setMethod(val); }
java
@Override public void setMethod(MethodValues method) { this.myMethod = method; super.setFirstLineChanged(); if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled()) { Tr.event(tc, "setMethod(v): " + (null != method ? method.getName() : null)); } }
java
@Override final public String getRequestURI() { if (null == this.myURIString) { this.myURIString = GenericUtils.getEnglishString(this.myURIBytes); } return this.myURIString; }
java
private String getTargetHost() { String host = getVirtualHost(); if (null == host) { host = (isIncoming()) ? getServiceContext().getLocalAddr().getCanonicalHostName() : getServiceContext().getRemoteAddr().getCanonicalHostName(); } return host; }
java
private int getTargetPort() { int port = getVirtualPort(); if (NOTSET == port) { port = (isIncoming()) ? getServiceContext().getLocalPort() : getServiceContext().getRemotePort(); } return port; }
java
@Override public int getVirtualPort() { if (HeaderStorage.NOTSET != this.iUrlPort) { // use the port from the parsed URL return this.iUrlPort; } if (NOT_PRESENT <= this.iHdrPort) { // already searched the header value and either found it or not, // either way, return what we saved return this.iHdrPort; } // need to extract the value from the header byte[] host = getHeader(HttpHeaderKeys.HDR_HOST).asBytes(); if (null == host || host.length == 0) { if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) { Tr.debug(tc, "getVirtualPort: No/empty host header"); } return -1; } // default to not_present now this.iHdrPort = NOT_PRESENT; int start = -1; if (LEFT_BRACKET == host[0]) { // IPV6 IP address start = GenericUtils.byteIndexOf(host, RIGHT_BRACKET, 0); if (-1 == start) { // invalid IP if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) { Tr.debug(tc, "getVirtualPort: Invalid IPV6 ip in host header"); } return -1; } start++; // skip past the bracket } else { // everything but an IPV6 IP start = GenericUtils.byteIndexOf(host, BNFHeaders.COLON, 0); } if (-1 == start || host.length <= start || BNFHeaders.COLON != host[start]) { if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) { Tr.debug(tc, "getVirtualPort: No port in host header"); } return -1; } start++; // skip past the colon int length = host.length - start; if (0 >= length) { if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) { Tr.debug(tc, "getVirtualPort: No port after colon"); } return -1; } try { // PK14634 - cache the parsed port this.iHdrPort = GenericUtils.asIntValue(host, start, length); } catch (NumberFormatException nfe) { // no FFDC required if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) { Tr.debug(tc, "getVirtualPort: Invalid port value: " + HttpChannelUtils.getEnglishString(host, start, length)); } return -1; } if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) { Tr.debug(tc, "getVirtualPort: returning " + this.iHdrPort); } return this.iHdrPort; }
java
private void parseURI(byte[] data, int start) { // at this point, we're parsing /URI [?querystring] if (start >= data.length) { // PK22096 - default to "/" if not found, should have caught empty // string inputs previously (http://host:port is valid) this.myURIBytes = SLASH; if (tc.isDebugEnabled()) { Tr.debug(tc, "Defaulting to slash since no URI data found"); } return; } int uri_end = data.length; for (int i = start; i < data.length; i++) { // look for the query string marker if ('?' == data[i]) { uri_end = i; break; } } // save off the URI if (start == uri_end) { // no uri found throw new IllegalArgumentException("Missing URI: " + GenericUtils.getEnglishString(data)); } if (0 == start && uri_end == data.length) { this.myURIBytes = data; } else { this.myURIBytes = new byte[uri_end - start]; System.arraycopy(data, start, this.myURIBytes, 0, this.myURIBytes.length); uri_end++; // jump past the '?' if (uri_end < data.length) { // save off the query string data byte[] query = new byte[data.length - uri_end]; System.arraycopy(data, uri_end, query, 0, query.length); setQueryString(query); } } }
java
private void parseScheme(byte[] data) { // we know the first character is correct, find the colon for (int i = 1; i < data.length; i++) { if (':' == data[i]) { SchemeValues val = SchemeValues.match(data, 0, i); if (null == val) { throw new IllegalArgumentException("Invalid scheme inside URL: " + GenericUtils.getEnglishString(data)); } setScheme(val); // scheme should be followed by "://" if ((i + 2) >= data.length || ('/' != data[i + 1] || '/' != data[i + 2])) { throw new IllegalArgumentException("Invalid net_path: " + GenericUtils.getEnglishString(data)); } parseAuthority(data, i + 3); return; } } // no colon found throw new IllegalArgumentException("Invalid scheme in URL: " + GenericUtils.getEnglishString(data)); }
java
@Override public void setRequestURI(byte[] uri) { if (null == uri || 0 == uri.length) { throw new IllegalArgumentException("setRequestURI: null input"); } super.setFirstLineChanged(); if ('*' == uri[0]) { // URI of "*" can only be one character long to be valid if (1 != uri.length && '?' != uri[1]) { String value = GenericUtils.getEnglishString(uri); if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) { Tr.debug(tc, "setRequestURI: invalid uri [" + value + "]"); } throw new IllegalArgumentException("Invalid uri: " + value); } } else if ('/' != uri[0]) { String value = GenericUtils.getEnglishString(uri); if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) { Tr.debug(tc, "setRequestURI: invalid uri [" + value + "]"); } throw new IllegalArgumentException("Invalid uri: " + value); } initScheme(); this.myURIString = null; this.sUrlHost = null; this.iUrlPort = HeaderStorage.NOTSET; this.myQueryBytes = null; this.queryParams = null; parseURI(uri, 0); if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) { Tr.debug(tc, "setRequestURI: set URI to " + getRequestURI()); } }
java
public void initScheme() { // set the scheme based on whether the socket is secure or not if (null == getServiceContext() || null == getServiceContext().getTSC()) { // discrimination path, not ready for this yet return; } if (getServiceContext().isSecure()) { this.myScheme = SchemeValues.HTTPS; } else { this.myScheme = SchemeValues.HTTP; } }
java
@Override public String getScheme() { // if it hasn't been set yet, then check whether the SC is secure // or not and set the value accordingly if (null == this.myScheme) { initScheme(); } if (null == this.myScheme) { // if the request has been already destroyed then it will be still null return null; } return this.myScheme.getName(); }
java
@Override public void setScheme(SchemeValues scheme) { this.myScheme = scheme; super.setFirstLineChanged(); if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) { Tr.debug(tc, "setScheme(v): " + (null != scheme ? scheme.getName() : null)); } }
java
private void deserializeMethod(ObjectInput stream) throws IOException, ClassNotFoundException { MethodValues method = null; if (SERIALIZATION_V2 == getDeserializationVersion()) { method = MethodValues.find(readByteArray(stream)); } else { method = MethodValues.find((String) stream.readObject()); } if (null == method) { throw new IOException("Missing method"); } setMethod(method); }
java
private void deserializeScheme(ObjectInput stream) throws IOException, ClassNotFoundException { SchemeValues scheme = null; if (SERIALIZATION_V2 == getDeserializationVersion()) { byte[] value = readByteArray(stream); if (null == value) { throw new IOException("Missing scheme"); } scheme = SchemeValues.find(value); } else { String value = (String) stream.readObject(); scheme = SchemeValues.find(value); } setScheme(scheme); }
java
private synchronized void parseParameters() { if (null != this.queryParams) { // already parsed return; } if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) { Tr.debug(tc, "parseParameters for " + this); } String encoding = getCharset().name(); // PQ99481... non-English environments are too complex at the moment due to // the fact that current clients are not enforcing the proper Content-Type // header usage therefore figuring out what encoding to use involves system // properties, WAS config files, etc. So query parameters will only be // pulled // from the URI and not POST formdata // now merge in any possible URL params String queryString = getQueryString(); if (null != queryString) { if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) { Tr.debug(tc, "Parsing URL query data"); } this.queryParams = HttpChannelUtils.parseQueryString(queryString, encoding); } else { // if we didn't have any data then just create an empty table if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) { // PQ99481 Tr.debug(tc, "No parameter data found in body or URL"); Tr.debug(tc, "No query data found in URL"); } this.queryParams = new Hashtable<String, String[]>(); } }
java
protected void setDataSourceFactory(ServiceReference<ResourceFactory> ref) { if (TraceComponent.isAnyTracingEnabled() && LoggingUtil.SESSION_LOGGER_WAS.isLoggable(Level.FINE)) { LoggingUtil.SESSION_LOGGER_WAS.logp(Level.FINE, methodClassName, "setDataSourceFactory", "setting " + ref); } dataSourceFactoryRef.setReference(ref); }
java
protected void unsetDataSourceFactory(ServiceReference<ResourceFactory> ref) { if (TraceComponent.isAnyTracingEnabled() && LoggingUtil.SESSION_LOGGER_WAS.isLoggable(Level.FINE)) { LoggingUtil.SESSION_LOGGER_WAS.logp(Level.FINE, methodClassName, "unsetDataSourceFactory", "unsetting " + ref); } dataSourceFactoryRef.unsetReference(ref); }
java
protected void setResourceConfigFactory(ServiceReference<ResourceConfigFactory> ref) { if (TraceComponent.isAnyTracingEnabled() && LoggingUtil.SESSION_LOGGER_WAS.isLoggable(Level.FINE)) { LoggingUtil.SESSION_LOGGER_WAS.logp(Level.FINE, methodClassName, "setResourceConfigFactory", "setting " + ref); } resourceConfigFactoryRef.setReference(ref); }
java
protected void unsetResourceConfigFactory(ServiceReference<ResourceConfigFactory> ref) { if (TraceComponent.isAnyTracingEnabled() && LoggingUtil.SESSION_LOGGER_WAS.isLoggable(Level.FINE)) { LoggingUtil.SESSION_LOGGER_WAS.logp(Level.FINE, methodClassName, "unsetResourceConfigFactory", "unsetting " + ref); } resourceConfigFactoryRef.unsetReference(ref); }
java
protected void setLocalTransactionCurrent(ServiceReference<LocalTransactionCurrent> ref) { if (TraceComponent.isAnyTracingEnabled() && LoggingUtil.SESSION_LOGGER_WAS.isLoggable(Level.FINE)) { LoggingUtil.SESSION_LOGGER_WAS.logp(Level.FINE, methodClassName, "setLocalTransactionCurrent", "setting " + ref); } localTransactionCurrentRef.setReference(ref); }
java
protected void unsetLocalTransactionCurrent(ServiceReference<LocalTransactionCurrent> ref) { if (TraceComponent.isAnyTracingEnabled() && LoggingUtil.SESSION_LOGGER_WAS.isLoggable(Level.FINE)) { LoggingUtil.SESSION_LOGGER_WAS.logp(Level.FINE, methodClassName, "unsetLocalTransactionCurrent", "unsetting " + ref); } localTransactionCurrentRef.unsetReference(ref); }
java
protected void setEmbeddableWebSphereTransactionManager(ServiceReference<EmbeddableWebSphereTransactionManager> ref) { if (TraceComponent.isAnyTracingEnabled() && LoggingUtil.SESSION_LOGGER_WAS.isLoggable(Level.FINE)) { LoggingUtil.SESSION_LOGGER_WAS.logp(Level.FINE, methodClassName, "setEmbeddableWebSphereTransactionManager", "setting " + ref); } embeddableWebSphereTransactionManagerRef.setReference(ref); }
java
protected void unsetEmbeddableWebSphereTransactionManager(ServiceReference<EmbeddableWebSphereTransactionManager> ref) { if (TraceComponent.isAnyTracingEnabled() && LoggingUtil.SESSION_LOGGER_WAS.isLoggable(Level.FINE)) { LoggingUtil.SESSION_LOGGER_WAS.logp(Level.FINE, methodClassName, "unsetEmbeddableWebSphereTransactionManager", "unsetting " + ref); } embeddableWebSphereTransactionManagerRef.unsetReference(ref); }
java
protected void setUowCurrent(ServiceReference<UOWCurrent> ref) { if (TraceComponent.isAnyTracingEnabled() && LoggingUtil.SESSION_LOGGER_WAS.isLoggable(Level.FINE)) { LoggingUtil.SESSION_LOGGER_WAS.logp(Level.FINE, methodClassName, "setUowCurrent", "setting " + ref); } uowCurrentRef.setReference(ref); }
java
protected void unsetUowCurrent(ServiceReference<UOWCurrent> ref) { if (TraceComponent.isAnyTracingEnabled() && LoggingUtil.SESSION_LOGGER_WAS.isLoggable(Level.FINE)) { LoggingUtil.SESSION_LOGGER_WAS.logp(Level.FINE, methodClassName, "unsetUowCurrent", "unsetting " + ref); } uowCurrentRef.unsetReference(ref); }
java
protected void setUserTransaction(ServiceReference<UserTransaction> ref) { if (TraceComponent.isAnyTracingEnabled() && LoggingUtil.SESSION_LOGGER_WAS.isLoggable(Level.FINE)) { LoggingUtil.SESSION_LOGGER_WAS.logp(Level.FINE, methodClassName, "setUserTransaction", "setting " + ref); } userTransactionRef.setReference(ref); }
java
protected void unsetUserTransaction(ServiceReference<UserTransaction> ref) { if (TraceComponent.isAnyTracingEnabled() && LoggingUtil.SESSION_LOGGER_WAS.isLoggable(Level.FINE)) { LoggingUtil.SESSION_LOGGER_WAS.logp(Level.FINE, methodClassName, "unsetUserTransaction", "unsetting " + ref); } userTransactionRef.unsetReference(ref); }
java
protected void setSerializationService(ServiceReference<SerializationService> ref) { if (TraceComponent.isAnyTracingEnabled() && LoggingUtil.SESSION_LOGGER_WAS.isLoggable(Level.FINE)) { LoggingUtil.SESSION_LOGGER_WAS.logp(Level.FINE, methodClassName, "setSerializationService", "setting " + ref); } serializationServiceRef.setReference(ref); }
java
protected void unsetSerializationService(ServiceReference<SerializationService> ref) { if (TraceComponent.isAnyTracingEnabled() && LoggingUtil.SESSION_LOGGER_WAS.isLoggable(Level.FINE)) { LoggingUtil.SESSION_LOGGER_WAS.logp(Level.FINE, methodClassName, "unsetSerializationService", "unsetting " + ref); } serializationServiceRef.unsetReference(ref); }
java
private Connection getJdbcConnection() throws JspCoreException, SQLException { Connection conn = null; String url = getConnProperties().getUrl(); String user = getConnProperties().getLoginUser(); String passwd = getConnProperties().getLoginPasswd(); String jndiName = getConnProperties().getJndiName(); //System.out.println("***** Query.getJdbcConnection(): jndiname = " + jndiName); if (jndiName == null) { // use driver manager // load driver String dbDriver = (getConnProperties()).getDbDriver(); try { Class.forName(dbDriver); conn = DriverManager.getConnection(url, user, passwd); } // try load driver catch (ClassNotFoundException e) { //com.ibm.ws.ffdc.FFDCFilter.processException(e, "com.ibm.ws.webcontainer.jsp.tsx.db.Query.getJdbcConnection", "174", this); throw new JspCoreException(JspConstants.InvalidDbDriver + dbDriver); } // catch } // if jndiname == null else { // use datasource DataSource ds; try { ds = getSingleton(jndiName); } catch (Throwable th) { //com.ibm.ws.ffdc.FFDCFilter.processException(th, "com.ibm.ws.webcontainer.jsp.tsx.db.Query.getJdbcConnection", "184", this); throw new JspCoreException(JspConstants.DatasourceException + th.getMessage()); } conn = ds.getConnection(user, passwd); } return conn; }
java
public static boolean isAbsolutePath(String uri) { boolean absolute = false; if (uri != null) { if (uri.indexOf(":/") != -1) { absolute = true; } else if (uri.indexOf(":\\") != -1) { absolute = true; } } return absolute; }
java
private static boolean equalsHashes(File fileToHash, String hashToCompare) throws IOException { boolean result = false; // Now calculate the new hash and compare the 2. If they are NOT the same the ifix needs to be re-applied. String fileHash = MD5Utils.getFileMD5String(fileToHash); if (fileHash.equals(hashToCompare)) result = true; return result; }
java
private static Map<String, IFixInfo> processIFixXmls(File wlpInstallationDirectory, Map<String, BundleFile> bundleFiles, CommandConsole console) { // A map of update file names and the IfixInfo objects that contain the latest versions of these files. Map<String, IFixInfo> filteredIfixInfos = new HashMap<String, IFixInfo>(); // A map of updated file names and the UpdateFile Object that represents the latest version of the file. // We use this map so that we don't have to find the file in the ifix info object each time. Map<String, UpdatedFile> latestIfixFiles = new HashMap<String, UpdatedFile>(); // Get the full list of XML files Set<IFixInfo> ifixInfos = getInstalledIFixes(wlpInstallationDirectory, console); // Iterate over each one and process each file. for (IFixInfo chkinfo : ifixInfos) { // For each ifix, list all of the updated files for (UpdatedFile updateFile : chkinfo.getUpdates().getFiles()) { // See if we have an existing entry in the map of existing files. If not, add this one to the map, otherwise // check to see if this file has a more recent date than the one stored. If it does, then // replace the existing one with this new entry. String existingUpdateFileID; String updateId = updateFile.getId(); // If we have a jar file, then we need to find the existing id which won't be the same as our current one, because the ifix qualifiers are // different for each ifix jar. if (bundleFiles.containsKey(updateId)) { existingUpdateFileID = getExistingMatchingIfixID(bundleFiles.get(updateId), latestIfixFiles.keySet(), bundleFiles); } else { // If we're not a jar but a static file, then use the updateID to find the existing values. existingUpdateFileID = updateId; } // If we've got an existing entry and the date of the currently processed updateFile has a greater date, // then remove the old version and replace it with the new one. UpdatedFile existingUpdateFile = latestIfixFiles.get(existingUpdateFileID); if (existingUpdateFile != null) { int dateComparison = updateFile.getDate().compareTo(existingUpdateFile.getDate()); boolean replaceInMap = false; if (dateComparison > 0) replaceInMap = true; else if (dateComparison == 0) { //the same file had the same date in two fixes //check the number of problems being resolved IFixInfo existingFixInfo = filteredIfixInfos.get(existingUpdateFileID); List<Problem> existingProblems = existingFixInfo.getResolves().getProblems(); List<Problem> problems = chkinfo.getResolves().getProblems(); //since fixes are cumulative, whichever resolves more problems is newer if (existingProblems.size() < problems.size()) replaceInMap = true; } if (replaceInMap) { filteredIfixInfos.remove(existingUpdateFileID); latestIfixFiles.remove(existingUpdateFileID); filteredIfixInfos.put(updateId, chkinfo); latestIfixFiles.put(updateId, updateFile); } } else { // If we don't have an existing entry, add this new entry. filteredIfixInfos.put(updateId, chkinfo); latestIfixFiles.put(updateId, updateFile); } } } return filteredIfixInfos; }
java
private static String getExistingMatchingIfixID(BundleFile bundleFile, Set<String> existingIDs, Map<String, BundleFile> bundleFiles) { String existingIfixKey = null; // Iterate over the known ids. for (String existingID : existingIDs) { // If we have a corresponding BundleFile for the existing ID, we need to check it matches the currently processed file. if (bundleFiles.containsKey(existingID)) { BundleFile existingBundleFile = bundleFiles.get(existingID); // If our symbolic name match the supplied BundleFile then move on to the version checking. if (bundleFile.getSymbolicName().equals(existingBundleFile.getSymbolicName())) { //Get the versions of both the checking bundle and the existing bundle. Check that the version, excluding the qualifier match // and if they do, we have a match. Version existingBundleVersion = new Version(existingBundleFile.getVersion()); Version bundleVersion = new Version(bundleFile.getVersion()); if (bundleVersion.getMajor() == existingBundleVersion.getMajor() && bundleVersion.getMinor() == existingBundleVersion.getMinor() && bundleVersion.getMicro() == existingBundleVersion.getMicro()) existingIfixKey = existingID; } } } return existingIfixKey; }
java
private static Map<String, BundleFile> processLPMFXmls(File wlpInstallationDirectory, CommandConsole console) { // A map of update file names and the IfixInfo objects that contain the latest versions of these files. Map<String, BundleFile> bundleFiles = new HashMap<String, BundleFile>(); // Iterate over each Liberty Profile Metadata file and process each bundle. for (LibertyProfileMetadataFile chklpmf : getInstalledLibertyProfileMetadataFiles(wlpInstallationDirectory, console)) { // For each metadata file, list all of the bundle files Bundles bundles = chklpmf.getBundles(); if (bundles != null) { List<BundleFile> bundleEntries = bundles.getBundleFiles(); if (bundleEntries != null) { for (BundleFile bundleFile : bundleEntries) { // See if we have an existing entry in the map of existing files. If not, add this one to the map, otherwise // check to see if this file has a more recent date than the one stored. If it does, then // replace the existing one with this new entry. bundleFiles.put(bundleFile.getId(), bundleFile); } } } } return bundleFiles; }
java
public static String getEntityType(String accessId) { Matcher m = matcher(accessId); if (m != null) { return m.group(1); } return null; }
java
public static String getRealm(String accessId) { Matcher m = matcher(accessId); if (m != null) { return m.group(2); } return null; }
java
public static String getUniqueId(String accessId) { Matcher m = matcher(accessId); if (m != null) { return m.group(3); } return null; }
java
public static String getUniqueId(String accessId, String realm) { if (realm != null) { Pattern pattern = Pattern.compile("([^:]+):(" + Pattern.quote(realm) + ")/(.*)"); Matcher m = pattern.matcher(accessId); if (m.matches()) { if (m.group(3).length() > 0) { return m.group(3); } } } // if there is no match, fall back. return getUniqueId(accessId); }
java
private String replaceNonAlpha(String name) { String modifiedName = null; if (p != null) modifiedName = p.matcher(name).replaceAll("_"); return modifiedName; }
java
public void setConsumerDispatcher(ConsumerDispatcher consumerDispatcher) { if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(tc, "setConsumerDispatcher", consumerDispatcher); this.consumerDispatcher = consumerDispatcher; if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(tc, "setConsumerDispatcher"); }
java
@Override public void xmlWriteOn(FormattedWriter writer) throws IOException { if (consumerDispatcher != null) { writer.newLine(); writer.taggedValue("consumerDispatcher", consumerDispatcher.toString()); } }
java
public void deleteIfPossible(boolean startAsynchThread) { if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(tc, "deleteIfPossible", new Boolean(startAsynchThread)); // Lock exclusively to stop any further messages from being added. _subscriptionLockManager.lockExclusive(); try { if (destinationHandler == null) { // Get the transaction manager for the message processor PubSubMessageItemStream mis = (PubSubMessageItemStream) getItemStream(); destinationHandler = (DestinationHandler) mis.getItemStream(); } if (toBeDeleted || destinationHandler.isToBeDeleted()) { SIMPTransactionManager txManager = destinationHandler.getTxManager(); boolean complete = false; try { Statistics statistics = null; try { statistics = getStatistics(); } catch (NotInMessageStore e) { // No FFDC Code needed // This exception can be thrown if a Durable subscription was on a destination that // was deleted and it was a durable subscription which was already marked for deletion complete = true; if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(tc, "deleteIfPossible", "Subscription already deleted"); return; } long countOfAvailableItems = statistics.getAvailableItemCount(); /* * There may be itemreference which is locked for * delivery delay.Those messages must also be deleted. * Hence get the locked message count.Its imp to note that * all the messages will not be deleted only the messages which * are available or messages which are locked for delivery delay * will be deleted.That check is done in removeAllAvailableReferences() * where a DeliveryDelay filter is used. */ long countOfLockedMessages = statistics.getLockedItemCount(); if (countOfAvailableItems > 0 || countOfLockedMessages > 0) { //Remove any available references from the subscription. try { removeAllAvailableReferences(); } catch (SIResourceException e1) { // No FFDC code needed if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(tc, "deleteIfPossible", e1); // Exit so finally block run return; } } statistics = getStatistics(); long countOfTotalItems = statistics.getTotalItemCount(); if (countOfTotalItems == 0) { //All references are gone. The subscription can be removed. if (destinationHandler.isToBeDeleted()) { //It may now be possible to clean up the destination. Have a go! destinationHandler.getDestinationManager().markDestinationAsCleanUpPending(destinationHandler); } try { PubSubMessageItemStream parentItemStream = (PubSubMessageItemStream) getItemStream(); remove(txManager.createAutoCommitTransaction(), NO_LOCK_ID); parentItemStream.decrementReferenceStreamCount(); complete = true; } catch (MessageStoreException e) { FFDCFilter.processException( e, "com.ibm.ws.sib.processor.impl.store.itemstreams.SubscriptionItemStream.deleteIfPossible", "1:364:1.54", this); SibTr.exception(tc, e); SibTr.error(tc, "INTERNAL_MESSAGING_ERROR_CWSIP0002", new Object[] { "com.ibm.ws.sib.processor.impl.store.itemstreams.SubscriptionItemStream", "1:371:1.54", e }); } } } catch (Exception e) { // No FFDC code needed // Log that this exception occured SibTr.exception(tc, e); } finally { if (!complete) { destinationHandler.getDestinationManager().addSubscriptionToDelete(this); if (startAsynchThread) destinationHandler.getDestinationManager().startAsynchDeletion(); } } } } catch (MessageStoreException e) { FFDCFilter.processException( e, "com.ibm.ws.sib.processor.impl.store.itemstreams.SubscriptionItemStream.deleteIfPossible", "1:400:1.54", this); SibTr.exception(tc, e); SibTr.error(tc, "INTERNAL_MESSAGING_ERROR_CWSIP0002", new Object[] { "com.ibm.ws.sib.processor.impl.store.itemstreams.SubscriptionItemStream", "1:407:1.54", e }); } finally { // Finally unlock the lock manager _subscriptionLockManager.unlockExclusive(); } if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(tc, "deleteIfPossible"); return; }
java
public void markAsToBeDeleted() { if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(tc, "markAsToBeDeleted"); toBeDeleted = true; if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(tc, "markAsToBeDeleted"); }
java
public void removeAllAvailableReferences() throws SIResourceException { if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(tc, "removeAllAvailableReferences"); LocalTransaction transaction = null; ItemReference itemReference = null; try { // Get the transaction manager for the message processor PubSubMessageItemStream mis = (PubSubMessageItemStream) getItemStream(); DestinationHandler dh = (DestinationHandler) mis.getItemStream(); SIMPTransactionManager txManager = dh.getTxManager(); removingAvailableReferences = true; if (txManager != null) { /* Create new transaction */ transaction = txManager.createLocalTransaction(true); int countOfItems = 0; //Remove all the references in batches to avoid large UOWs in the msgstore do { do { /* * Introduce a new DeliveryDelayDeleteFilter which basically retrieves * the messages which are either available or which are locked * for delivery delay It is just a marker class.Earlier to * delivery delay feature null was being passed */ itemReference = this.removeFirstMatching(new DeliveryDelayDeleteFilter(), (Transaction) transaction); if (itemReference != null) countOfItems++; } while ((itemReference != null) && (countOfItems < BATCH_DELETE_SIZE)); //Commit the batch if (countOfItems > 0) { transaction.commit(); /* Create new transaction */ if (itemReference != null) { transaction = txManager.createLocalTransaction(true); } countOfItems = 0; } } while (itemReference != null); } } catch (MessageStoreException e) { FFDCFilter.processException( e, "com.ibm.ws.sib.processor.impl.store.itemstreams.SubscriptionItemStream.removeAllAvailableReferences", "1:509:1.54", this); SibTr.exception(tc, e); SibTr.error(tc, "INTERNAL_MESSAGING_ERROR_CWSIP0002", new Object[] { "com.ibm.ws.sib.processor.impl.store.itemstreams.SubscriptionItemStream", "1:516:1.54", e }); if (transaction != null) handleRollback(transaction); if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(tc, "removeAllAvailableReferences"); throw new SIResourceException( nls.getFormattedMessage( "INTERNAL_MESSAGING_ERROR_CWSIP0002", new Object[] { "com.ibm.ws.sib.processor.impl.store.itemstreams.SubscriptionItemStream", "1:530:1.54", e }, null), e); } catch (SIException e) { FFDCFilter.processException( e, "com.ibm.ws.sib.processor.impl.store.itemstreams.SubscriptionItemStream.removeAllAvailableReferences", "1:540:1.54", this); SibTr.exception(tc, e); SibTr.error(tc, "INTERNAL_MESSAGING_ERROR_CWSIP0002", new Object[] { "com.ibm.ws.sib.processor.impl.store.itemstreams.SubscriptionItemStream", "1:547:1.54", e }); if (transaction != null) handleRollback(transaction); if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(tc, "removeAllAvailableReferences"); throw new SIResourceException( nls.getFormattedMessage( "INTERNAL_MESSAGING_ERROR_CWSIP0002", new Object[] { "com.ibm.ws.sib.processor.impl.store.itemstreams.SubscriptionItemStream", "1:561:1.54", e }, null), e); } if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(tc, "removeAllAvailableReferences"); }
java
public LockManager getSubscriptionLockManager() { if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) { SibTr.entry(tc, "getSubscriptionLockManager"); SibTr.exit(tc, "getSubscriptionLockManager", _subscriptionLockManager); } return _subscriptionLockManager; }
java
@Trivial private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { GetField fields = in.readFields(); failure = (Throwable) fields.get(FAILURE, null); previousResult = (byte[]) fields.get(PREVIOUS_RESULT, null); }
java
@Trivial private void writeObject(ObjectOutputStream out) throws IOException { PutField fields = out.putFields(); fields.put(FAILURE, failure); fields.put(PREVIOUS_RESULT, previousResult); out.writeFields(); }
java
public static <T> StaticValue<T> mutateStaticValue(StaticValue<T> staticValue, Callable<T> initializer) { if (multiplex) { // Multiplexing case; must check for existing StaticValue if (staticValue == null) { // no existing value; create new one with no constructor initializer staticValue = StaticValue.createStaticValue(null); } // initialize this thread only with the initializer staticValue.initialize(getThreadGroup(), initializer); return staticValue; } // Final singleton case; just create a new StaticValue return StaticValue.createStaticValue(initializer); }
java
public static Object concat(Object[] arrs) { int totalLen = 0; Class commonComponentType = null; for (int i = 0, len = arrs.length; i < len; i++) { // skip all null arrays if (arrs[i] == null) { continue; } int arrayLen = Array.getLength(arrs[i]); // skip all empty arrays if (arrayLen == 0) { continue; } totalLen += arrayLen; Class componentType = arrs[i].getClass().getComponentType(); commonComponentType = (commonComponentType == null) ? componentType : commonClass(commonComponentType, componentType); } if (commonComponentType == null) { return null; } return concat(Array.newInstance(commonComponentType, totalLen), totalLen, arrs); }
java
@Override public int compare(T entity1, T entity2) { SortHandler shandler = new SortHandler(sortControl); return shandler.compareEntitysWithRespectToProperties((Entity) entity1, (Entity) entity2); }
java
public void dump() { if (!tc.isDumpEnabled()) { return; } Enumeration vEnum = lockTable.keys(); Tr.dump(tc, "-- Lock Manager Dump --"); while (vEnum.hasMoreElements()) { Object key = vEnum.nextElement(); Tr.dump(tc, "lock table entry", new Object[] { key, lockTable.get(key) }); } }
java
protected Commandline getCommandline() { Commandline cmdl = new Commandline(); if (configFile != null) { cmdl.createArgument().setValue("--config"); cmdl.createArgument().setFile(configFile); } if (debug) { cmdl.createArgument().setValue("--debug"); } return cmdl; }
java
@Override public void execute() { List<File> flist = new ArrayList<File>(); if (file != null) { flist.add(file); } for (int i = 0; i < filesets.size(); i++) { FileSet fs = filesets.elementAt(i); DirectoryScanner ds = fs.getDirectoryScanner(getProject()); File dir = fs.getDir(getProject()); String[] includedFiles = ds.getIncludedFiles(); for (String s : Arrays.asList(includedFiles)) { flist.add(new File(dir, s)); } } Commandline cmdl = getCommandline(); for (File f : flist) { cmdl.createArgument().setFile(f); } AbstractInstrumentation inst; try { inst = createInstrumentation(); if (cmdl.size() == 0) { return; } inst.processArguments(cmdl.getArguments()); inst.processPackageInfo(); } catch (Exception t) { getProject().log(this, "Invalid class files or jars specified " + t, Project.MSG_ERR); if (failOnError) { getProject().log("Instrumentation Failed", t, Project.MSG_ERR); throw new BuildException("InstrumentationFailed", t); } else { return; } } List<File> classFiles = inst.getClassFiles(); List<File> jarFiles = inst.getJarFiles(); // I don't remember why I did this // inst.setClassFiles(null); // inst.setJarFiles(null); boolean instrumentationErrors = false; for (File f : classFiles) { try { log("Instrumenting class " + f, verbosity); inst.instrumentClassFile(f); } catch (Throwable t) { boolean instrumentationError = t instanceof InstrumentationException; if (failOnError && !instrumentationError) { throw new BuildException("Instrumentation of class " + f + " failed", t); } else { String reason = ""; if (instrumentationError) { reason = ": " + t.getMessage(); instrumentationErrors = true; } getProject().log(this, "Unable to instrument class " + f + reason, Project.MSG_WARN); } } } for (File f : jarFiles) { try { log("Instrumenting archive file " + f, verbosity); inst.instrumentZipFile(f); } catch (Throwable t) { if (failOnError) { throw new BuildException("InstrumentationFailed", t); } else { getProject().log(this, "Unable to instrument archive " + f, Project.MSG_WARN); } } } if (instrumentationErrors) { throw new BuildException("Instrumentation of classes failed"); } }
java
private ReturnCode write(String command, ReturnCode notStartedRC, ReturnCode errorRC) { SocketChannel channel = null; try { ServerCommandID commandID = createServerCommand(command); if (commandID.getPort() > 0) { channel = SelectorProvider.provider().openSocketChannel(); channel.connect(new InetSocketAddress(InetAddress.getByName(null), commandID.getPort())); // Write command. write(channel, commandID.getCommandString()); // Receive authorization challenge. String authID = read(channel); // Respond to authorization challenge. File authFile = new File(commandAuthDir, authID); // Delete a file created by the server (check for write access) authFile.delete(); // respond to the server to indicate the delete has happened. write(channel, authID); // Read command response. String cmdResponse = read(channel), targetServerUUID = null, responseCode = null; if (cmdResponse.isEmpty()) { throw new IOException("connection closed by server without a reply"); } if (cmdResponse.indexOf(DELIM) != -1) { targetServerUUID = cmdResponse.substring(0, cmdResponse.indexOf(DELIM)); responseCode = cmdResponse.substring(cmdResponse.indexOf(DELIM) + 1); } else { targetServerUUID = cmdResponse; } if (!commandID.validateTarget(targetServerUUID)) { throw new IOException("command file mismatch"); } ReturnCode result = ReturnCode.OK; if (responseCode != null) { try { int returnCode = Integer.parseInt(responseCode.trim()); result = ReturnCode.getEnum(returnCode); } catch (NumberFormatException nfe) { throw new IOException("invalid return code"); } } if (result == ReturnCode.INVALID) { throw new IOException("invalid return code"); } return result; } if (commandID.getPort() == -1) { return ReturnCode.SERVER_COMMAND_PORT_DISABLED_STATUS; } return notStartedRC; } catch (ConnectException e) { Debug.printStackTrace(e); return notStartedRC; } catch (IOException e) { Debug.printStackTrace(e); return errorRC; } finally { Utils.tryToClose(channel); } }
java
public ReturnCode startStatus(ServerLock lock) { // The server process might not have created the command file yet. // Wait for it to appear. while (!isValid()) { ReturnCode rc = startStatusWait(lock); if (rc != ReturnCode.START_STATUS_ACTION) { return rc; } } for (int i = 0; i < BootstrapConstants.MAX_POLL_ATTEMPTS && isValid(); i++) { // Try to connect to the server's command file. This might fail if // the command file is written but the server hasn't opened the // socket yet. ReturnCode rc = write(STATUS_START_COMMAND, ReturnCode.START_STATUS_ACTION, ReturnCode.ERROR_SERVER_START); if (rc != ReturnCode.START_STATUS_ACTION) { return rc; } // Wait a bit, ensuring that the server process is still running. rc = startStatusWait(lock); if (rc != ReturnCode.START_STATUS_ACTION) { return rc; } } return write(STATUS_START_COMMAND, ReturnCode.ERROR_SERVER_START, ReturnCode.ERROR_SERVER_START); }
java
private ReturnCode startStatusWait(ServerLock lock) { try { Thread.sleep(BootstrapConstants.POLL_INTERVAL_MS); } catch (InterruptedException ex) { Debug.printStackTrace(ex); return ReturnCode.ERROR_SERVER_START; } // This method is only called if the server process was holding // the server lock. If this process is suddenly able to obtain the // lock, then the server process didn't finish starting. if (!lock.testServerRunning()) { return ReturnCode.ERROR_SERVER_START; } return ReturnCode.START_STATUS_ACTION; }
java
public ReturnCode stopServer(boolean force) { return write(force ? FORCE_STOP_COMMAND : STOP_COMMAND, ReturnCode.REDUNDANT_ACTION_STATUS, ReturnCode.ERROR_SERVER_STOP); }
java
public ReturnCode introspectServer(String dumpTimestamp, Set<JavaDumpAction> javaDumpActions) { // Since "server dump" is used for diagnostics, we go out of our way to // not send an unrecognized command to the server even if the user has // broken their environment such that the client process supports java // dumps but the server doesn't. String command; if (javaDumpActions.isEmpty()) { command = INTROSPECT_COMMAND + DELIM + dumpTimestamp; } else { StringBuilder commandBuilder = new StringBuilder().append(INTROSPECT_JAVADUMP_COMMAND).append(DELIM).append(dumpTimestamp); for (JavaDumpAction javaDumpAction : javaDumpActions) { commandBuilder.append(',').append(javaDumpAction.name()); } command = commandBuilder.toString(); } return write(command, ReturnCode.DUMP_ACTION, ReturnCode.ERROR_SERVER_DUMP); }
java
public ReturnCode javaDump(Set<JavaDumpAction> javaDumpActions) { StringBuilder commandBuilder = new StringBuilder(JAVADUMP_COMMAND); char sep = DELIM; for (JavaDumpAction javaDumpAction : javaDumpActions) { commandBuilder.append(sep).append(javaDumpAction.toString()); sep = ','; } return write(commandBuilder.toString(), ReturnCode.SERVER_INACTIVE_STATUS, ReturnCode.ERROR_SERVER_DUMP); }
java
public ReturnCode pause(String targetArg) { StringBuilder commandBuilder = new StringBuilder(PAUSE_COMMAND); char sep = DELIM; if (targetArg != null) { commandBuilder.append(sep).append(targetArg); } return write(commandBuilder.toString(), ReturnCode.SERVER_INACTIVE_STATUS, ReturnCode.ERROR_SERVER_PAUSE); }
java
public ReturnCode resume(String targetArg) { StringBuilder commandBuilder = new StringBuilder(RESUME_COMMAND); char sep = DELIM; if (targetArg != null) { commandBuilder.append(sep).append(targetArg); } return write(commandBuilder.toString(), ReturnCode.SERVER_INACTIVE_STATUS, ReturnCode.ERROR_SERVER_RESUME); }
java
public boolean contain(OidcTokenImplBase token) { //(IdToken token) { String key = token.getJwtId(); if (key == null) { return false; } key = getCacheKey(token); long currentTimeMilliseconds = (new Date()).getTime(); synchronized (primaryTable) { Long exp = (Long) primaryTable.get(key); // milliseconds if (exp != null) { if (exp.longValue() > currentTimeMilliseconds) { // not expired yet // milliseconds return true; } else { primaryTable.remove(key); } } // cache the jwt long tokenExp = token.getExpirationTimeSeconds() * 1000; // milliseconds if (tokenExp == 0) { // in case it's not set, let's give it one hour tokenExp = currentTimeMilliseconds + 60 * 60 * 1000; // 1 hour } primaryTable.put(key, Long.valueOf(tokenExp)); } return false; }
java
public final ResourceException isValid(int newAction) { try { setState(newAction, true); } catch (TransactionException exp) { FFDCFilter.processException(exp, "com.ibm.ws.rsadapter.spi.WSStateManager.isValid", "385", this); return exp; } return null; }
java