code
stringlengths
73
34.1k
label
stringclasses
1 value
public void quit() { try { this.keepOn = false; if (this.serverSocket != null && !this.serverSocket.isClosed()) { this.serverSocket.close(); this.serverSocket = null; } } catch (final IOException e) { throw new RuntimeException(e); } }
java
boolean contains(String normalizedPath) { if (normalizedPath == null) return false; if (normalizedPath.length() < normalizedRoot.length()) return false; return normalizedPath.regionMatches(0, normalizedRoot, 0, normalizedRoot.length()); }
java
private static String getIPAddress () { String rc; try { rc = InetAddress.getLocalHost().getHostAddress(); } catch (Exception e) { // No FFDC code needed rc = Long.valueOf(new Random().nextLong()).toString(); } return rc; }
java
private SecurityMetadata getSecurityMetadata(WebAppConfig webAppConfig) { WebModuleMetaData wmmd = ((WebAppConfigExtended) webAppConfig).getMetaData(); return (SecurityMetadata) wmmd.getSecurityMetaData(); }
java
private boolean isDenyUncoveredHttpMethods(List<SecurityConstraint> scList) { for (SecurityConstraint sc : scList) { List<WebResourceCollection> wrcList = sc.getWebResourceCollections(); for (WebResourceCollection wrc : wrcList) { if (wrc.getDenyUncoveredHttpMethods()) { return true; } } } return false; }
java
@Override public final DataSource createConnectionFactory(ConnectionManager connMgr) { final boolean isTraceOn = TraceComponent.isAnyTracingEnabled(); if (isTraceOn && tc.isEntryEnabled()) Tr.entry(this, tc, "createConnectionFactory", connMgr); DataSource connFactory = jdbcRuntime.newDataSource(this, connMgr); if (isTraceOn && tc.isEntryEnabled()) Tr.exit(this, tc, "createConnectionFactory", connFactory); return connFactory; }
java
private Connection getConnection(PooledConnection pconn, WSConnectionRequestInfoImpl cri, String userName) throws ResourceException { final boolean isTraceOn = TraceComponent.isAnyTracingEnabled(); if (isTraceOn && tc.isEntryEnabled()) Tr.entry(this, tc, "getConnection", AdapterUtil.toString(pconn)); Connection conn = null; boolean isConnectionSetupComplete = false; try { conn = pconn.getConnection(); postGetConnectionHandling(conn); isConnectionSetupComplete = true; } catch (SQLException se) { FFDCFilter.processException(se, getClass().getName(), "260", this); ResourceException x = AdapterUtil.translateSQLException(se, this, false, getClass()); if (isTraceOn && tc.isEntryEnabled()) Tr.exit(this, tc, "getConnection", se); throw x; } finally { // Destroy the connection if we weren't able to successfully complete the setup. if (!isConnectionSetupComplete) { if (conn != null) try { conn.close(); } catch (Throwable x) { } if (pconn != null) try { pconn.close(); } catch (Throwable x) { } } } if (isTraceOn && tc.isEntryEnabled()) Tr.exit(this, tc, "getConnection", AdapterUtil.toString(conn)); return conn; }
java
@Override public Set<ManagedConnection> getInvalidConnections(@SuppressWarnings("rawtypes") Set connectionSet) throws ResourceException { final boolean isTraceOn = TraceComponent.isAnyTracingEnabled(); if (isTraceOn && tc.isEntryEnabled()) Tr.entry(this, tc, "getInvalidConnections", connectionSet); Set<ManagedConnection> badSet = new HashSet<ManagedConnection>(); WSRdbManagedConnectionImpl mc = null; // Loop through each ManagedConnection in the list, using each connection's // preTestSQLString to check validity. Different connections can // have different preTestSQLStrings if they were created by different // ManagedConnectionFactories. for (Iterator<?> it = connectionSet.iterator(); it.hasNext();) { mc = (WSRdbManagedConnectionImpl) it.next(); if (!mc.validate()) badSet.add(mc); } if (isTraceOn && tc.isEntryEnabled()) Tr.exit(this, tc, "getInvalidConnections", badSet); return badSet; }
java
private Object getTraceable(Object d) throws ResourceException { WSJdbcTracer tracer = new WSJdbcTracer(helper.getTracer(), helper.getPrintWriter(), d, type, null, true); Set<Class<?>> classes = new HashSet<Class<?>>(); for (Class<?> cl = d.getClass(); cl != null; cl = cl.getSuperclass()) classes.addAll(Arrays.asList(cl.getInterfaces())); return Proxy.newProxyInstance(jdbcDriverLoader, classes.toArray(new Class[classes.size()]), tracer); }
java
private void onConnect(Connection con, String[] sqlCommands) throws SQLException { final boolean trace = TraceComponent.isAnyTracingEnabled(); TransactionManager tm = connectorSvc.getTransactionManager(); Transaction suspendedTx = null; String currentSQL = null; Throwable failure = null; try { UOWCoordinator coord = tm == null ? null : ((UOWCurrent) tm).getUOWCoord(); if (coord != null && coord.isGlobal()) suspendedTx = tm.suspend(); Statement stmt = con.createStatement(); for (String sql : sqlCommands) { currentSQL = sql; if (trace && tc.isDebugEnabled()) Tr.debug(this, tc, "execute onConnect SQL", sql); stmt.execute(sql); } stmt.close(); } catch (Throwable x) { failure = x; } if (suspendedTx != null) { try { tm.resume(suspendedTx); } catch (Throwable x) { failure = x; } } if (failure != null) { if (trace && tc.isDebugEnabled()) Tr.debug(this, tc, "failed", AdapterUtil.stackTraceToString(failure)); throw new SQLNonTransientConnectionException( AdapterUtil.getNLSMessage("DSRA4004.onconnect.sql", currentSQL, dsConfig.get().id), "08000", 0, failure); } }
java
private void postGetConnectionHandling(Connection conn) throws SQLException { helper.doConnectionSetup(conn); String[] sqlCommands = dsConfig.get().onConnect; if (sqlCommands != null && sqlCommands.length > 0) onConnect(conn, sqlCommands); // Log the database and driver versions on first getConnection. if (!wasUsedToGetAConnection) { // Wait until after the connection succeeds to set the indicator. // This accounts for the scenario where the first connection attempt is bad. // The information needs to be read again on the second attempt. helper.gatherAndDisplayMetaDataInfo(conn, this); wasUsedToGetAConnection = true; } }
java
final void reallySetLogWriter(final PrintWriter out) throws ResourceException { if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) Tr.debug(this, tc, "setting the logWriter to:", out); if (dataSourceOrDriver != null) { try { AccessController.doPrivileged(new PrivilegedExceptionAction<Void>() { public Void run() throws SQLException { if(!Driver.class.equals(type)) { ((CommonDataSource) dataSourceOrDriver).setLogWriter(out); } else { if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) Tr.debug(this, tc, "Unable to set logwriter on Driver type"); } return null; } }); } catch (PrivilegedActionException pae) { SQLException se = (SQLException) pae.getCause(); FFDCFilter.processException(se, getClass().getName(), "593", this); throw AdapterUtil.translateSQLException(se, this, false, getClass()); } } logWriter = out; // Keep the value only if successful on the DataSource. }
java
public final int getLoginTimeout() throws SQLException { try { if(!Driver.class.equals(type)) { return ((CommonDataSource) dataSourceOrDriver).getLoginTimeout(); } //Return that the default value is being used when using the Driver type return 0; } catch (SQLException sqlX) { FFDCFilter.processException(sqlX, getClass().getName(), "1670", this); throw AdapterUtil.mapSQLException(sqlX, this); } }
java
@Override public String formatRecord(RepositoryLogRecord record, Locale locale) { if (null == record) { throw new IllegalArgumentException("Record cannot be null"); } StringBuilder sb = new StringBuilder(300); String lineSeparatorPlusPadding = ""; // Use basic format createEventHeader(record, sb); lineSeparatorPlusPadding = svLineSeparatorPlusBasicPadding; // add the localizedMsg sb.append(formatMessage(record, locale)); // if we have a stack trace, append that to the formatted output. if (record.getStackTrace() != null) { sb.append(lineSeparatorPlusPadding); sb.append(record.getStackTrace()); } return sb.toString(); }
java
private void loadTldFromClassloader(GlobalTagLibConfig globalTagLibConfig, TldParser tldParser) { for (Iterator itr = globalTagLibConfig.getTldPathList().iterator(); itr.hasNext();) { TldPathConfig tldPathConfig = (TldPathConfig) itr.next(); InputStream is = globalTagLibConfig.getClassloader().getResourceAsStream(tldPathConfig.getTldPath()); JspInputSource tldInputSource = new JspInputSourceFromInputStreamImpl(is); if (com.ibm.ejs.ras.TraceComponent.isAnyTracingEnabled() && logger.isLoggable(Level.FINE)) { logger.logp(Level.FINE, CLASS_NAME, "loadTldFromClassloader", "tldInputSource.getRelativeURL(): [" + tldInputSource.getRelativeURL() + "]"); logger.logp(Level.FINE, CLASS_NAME, "loadTldFromClassloader", "tldInputSource.getAbsoluteURL(): [" + tldInputSource.getAbsoluteURL() + "]"); logger.logp(Level.FINE, CLASS_NAME, "loadTldFromClassloader", "tldInputSource.getContextURL(): [" + tldInputSource.getContextURL() + "]"); logger.logp(Level.FINE, CLASS_NAME, "loadTldFromClassloader", "globalTagLibConfig.getJarURL(): [" + globalTagLibConfig.getJarURL() + "]"); logger.logp(Level.FINE, CLASS_NAME, "loadTldFromClassloader", "tldPathConfig.getTldPath(): [" + tldPathConfig.getTldPath() + "]"); } try { TagLibraryInfoImpl tli = tldParser.parseTLD(tldInputSource, is, globalTagLibConfig.getJarURL().toExternalForm()); if (tli.getReliableURN() != null) { if (containsKey(tli.getReliableURN()) == false) { if (com.ibm.ejs.ras.TraceComponent.isAnyTracingEnabled() && logger.isLoggable(Level.FINE)) { logger.logp(Level.FINE, CLASS_NAME, "loadTldFromClassloader", "Global jar tld loaded for {0}", tli.getReliableURN()); } tli.setURI(tli.getReliableURN()); put(tli.getReliableURN(), tli); tldPathConfig.setUri(tli.getReliableURN()); eventListenerList.addAll(tldParser.getEventListenerList()); } } else { if (com.ibm.ejs.ras.TraceComponent.isAnyTracingEnabled() && logger.isLoggable(Level.WARNING)) { logger.logp(Level.WARNING, CLASS_NAME, "loadTldFromClassloader", "jsp warning failed to find a uri tag in [" + tldInputSource.getAbsoluteURL() + "]"); } } } catch (JspCoreException e) { if (com.ibm.ejs.ras.TraceComponent.isAnyTracingEnabled() && logger.isLoggable(Level.WARNING)) { logger.logp(Level.WARNING, CLASS_NAME, "loadTldFromClassloader", "jsp warning failed to load tld in jar. uri = [" + tldInputSource.getAbsoluteURL() + "]", e); } } } }
java
public void addGlobalTagLibConfig(GlobalTagLibConfig globalTagLibConfig) { try { TldParser tldParser = new TldParser(this, configManager, false, globalTagLibConfig.getClassloader()); if (globalTagLibConfig.getClassloader() == null) loadTldFromJarInputStream(globalTagLibConfig, tldParser); else loadTldFromClassloader(globalTagLibConfig, tldParser); globalTagLibConfigList.add(globalTagLibConfig); } catch (JspCoreException e) { if(com.ibm.ejs.ras.TraceComponent.isAnyTracingEnabled()&&logger.isLoggable(Level.SEVERE)){ logger.logp(Level.SEVERE, CLASS_NAME, "addGlobalTagLibConfig", "failed to create TldParser ", e); } } }
java
public static synchronized ClientConnectionManager getRef() { if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(tc, "getRef"); if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(tc, "getRef", instance); return instance; }
java
@Override public WSStatistic getStatistic(int dataId) { ArrayList members = copyStatistics(); if (members == null || members.size() <= 0) return null; int sz = members.size(); for (int i = 0; i < sz; i++) { StatisticImpl data = (StatisticImpl) members.get(i); if (data != null && data.getId() == dataId) { return data; } } return null; }
java
private synchronized void myupdate(WSStats newStats, boolean keepOld, boolean recursiveUpdate) { if (newStats == null) return; StatsImpl newStats1 = (StatsImpl) newStats; // update the level and description of this collection this.instrumentationLevel = newStats1.getLevel(); // update data updateMembers(newStats, keepOld); // update subcollections if (recursiveUpdate) updateSubcollection(newStats, keepOld, recursiveUpdate); }
java
public void insert(SimpleTest test, Object target) { if (size == ranges.length) { RangeEntry[] tmp = new RangeEntry[2*size]; System.arraycopy(ranges,0,tmp,0,size); ranges = tmp; } ranges[size] = new RangeEntry(test, target); size++; }
java
public Object getExact(SimpleTest test) { for (int i = 0; i < size; i++) { if (ranges[i].correspondsTo(test)) return ranges[i].target; } return null; }
java
public void replace(SimpleTest test, Object target) { for (int i = 0; i < size; i++) if (ranges[i].correspondsTo(test)) { ranges[i].target = target; return; } throw new IllegalStateException(); }
java
public List find(Number value) { // was NumericValue List targets = new ArrayList(1); for (int i = 0; i < size; i++) { if (ranges[i].contains(value)) targets.add(ranges[i].target); } return targets; }
java
@FFDCIgnore(XMLStreamException.class) public boolean parseServerConfiguration(InputStream in, String docLocation, BaseConfiguration config, MergeBehavior mergeBehavior) throws ConfigParserException, ConfigValidationException { XMLStreamReader parser = null; try { parser = getXMLInputFactory().createXMLStreamReader(docLocation, in); return parseServerConfiguration(new DepthAwareXMLStreamReader(parser), docLocation, config, mergeBehavior); } catch (XMLStreamException e) { throw new ConfigParserException(e); } finally { if (parser != null) { try { parser.close(); } catch (XMLStreamException e) { throw new ConfigParserException(e); } } } }
java
public void start(QueuedFuture<?> queuedFuture) { Runnable timeoutTask = () -> { queuedFuture.abort(new TimeoutException()); }; start(timeoutTask); }
java
private void timeout() { lock.writeLock().lock(); try { //if already stopped, do nothing, otherwise check times and run the timeout task if (!this.stopped) { long now = System.nanoTime(); long remaining = this.targetEnd - now; this.timedout = remaining <= FTConstants.MIN_TIMEOUT_NANO; if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) { debugTime("!Start {0}", this.start); debugTime("!Target {0}", this.targetEnd); debugTime("!Now {0}", now); debugTime("!Remain {0}", remaining); } //if we really have timedout then run the timeout task if (this.timedout) { debugRelativeTime("Timeout!"); this.timeoutTask.run(); } else { //this shouldn't be possible but if the timer popped too early, restart it debugTime("Premature Timeout!", remaining); start(this.timeoutTask, remaining); } } } finally { lock.writeLock().unlock(); } }
java
private void start(Runnable timeoutTask) { long timeout = timeoutPolicy.getTimeout().toNanos(); start(timeoutTask, timeout); }
java
private void start(Runnable timeoutTask, long remainingNanos) { lock.writeLock().lock(); try { this.timeoutTask = timeoutTask; this.start = System.nanoTime(); this.targetEnd = start + remainingNanos; if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) { debugTime(">Start {0}", this.start); debugTime(">Target {0}", this.targetEnd); debugTime(">Now {0}", this.start); debugTime(">Remain {0}", remainingNanos); } Runnable task = () -> { timeout(); }; if (remainingNanos > FTConstants.MIN_TIMEOUT_NANO) { this.future = scheduledExecutorService.schedule(task, remainingNanos, TimeUnit.NANOSECONDS); } else { task.run(); } } finally { lock.writeLock().unlock(); } }
java
public void stop() { lock.writeLock().lock(); try { debugRelativeTime("Stop!"); this.stopped = true; if (this.future != null && !this.future.isDone()) { debugRelativeTime("Cancelling"); this.future.cancel(true); } this.future = null; } finally { lock.writeLock().unlock(); } }
java
public void restart() { lock.writeLock().lock(); try { if (this.timeoutTask == null) { throw new IllegalStateException(Tr.formatMessage(tc, "internal.error.CWMFT4999E")); } stop(); this.stopped = false; start(this.timeoutTask); } finally { lock.writeLock().unlock(); } }
java
public long check() { long remaining = 0; lock.readLock().lock(); try { if (this.timedout) { // Note: this clears the interrupted flag if it was set // Assumption is that the interruption was caused by the Timeout boolean wasInterrupted = Thread.interrupted(); if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) { if (wasInterrupted) { Tr.debug(tc, "{0}: Throwing timeout exception and clearing interrupted flag", getDescriptor()); } else { Tr.debug(tc, "{0}: Throwing timeout exception", getDescriptor()); } } throw new TimeoutException(Tr.formatMessage(tc, "timeout.occurred.CWMFT0000E")); } long now = System.nanoTime(); remaining = this.targetEnd - now; if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) { debugTime("?Start ", this.start); debugTime("?Target", this.targetEnd); debugTime("?Now ", now); debugTime("?Remain", remaining); } } finally { lock.readLock().unlock(); } return remaining; }
java
@Trivial private void debugTime(String message, long nanos) { if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) { FTDebug.debugTime(tc, getDescriptor(), message, nanos); } }
java
public static String createPropertyFilter(String name, String value) { assert name.matches("[^=><~()]+"); StringBuilder builder = new StringBuilder(name.length() + 3 + (value == null ? 0 : value.length() * 2)); builder.append('(').append(name).append('='); int begin = 0; if (value != null) { for (int i = 0; i < value.length(); i++) { if ("\\*()".indexOf(value.charAt(i)) != -1) { builder.append(value, begin, i).append('\\'); begin = i; } } return builder.append(value, begin, value.length()).append(')').toString(); } else { return builder.append(')').toString(); } }
java
public static void delete(final File f) { if (f != null && f.exists()) { // Why do we have to specify a return type for the run method and paramatize // PrivilegedExceptionAction to it, this method should have a void return type ideally. AccessController.doPrivileged(new PrivilegedAction<Object>() { @Override public Object run() { if (!f.delete()) { logger.log(Level.INFO, Messages.INSTALL_KERNEL_MESSAGES.getLogMessage("LOG_CANNOT_DELETE_FILE", f.getAbsolutePath())); f.deleteOnExit(); } return null; } }); } }
java
public static FileInputStream getFileIputStream(final File file) throws FileNotFoundException { try { return AccessController.doPrivileged( new PrivilegedExceptionAction<FileInputStream>() { @Override public FileInputStream run() throws FileNotFoundException { return new FileInputStream(file); } }); } catch (PrivilegedActionException e) { // Creating a FileOutputStream can only return a FileNotFoundException throw (FileNotFoundException) e.getCause(); } }
java
public static long getFileLength(final File file) throws FileNotFoundException { try { return AccessController.doPrivileged( new PrivilegedExceptionAction<Long>() { @Override public Long run() throws FileNotFoundException { return file.length(); } }); } catch (PrivilegedActionException e) { // Creating a FileOutputStream can only return a FileNotFoundException throw (FileNotFoundException) e.getCause(); } }
java
JavaURLContext createJavaURLContext(Hashtable<?, ?> envmt, Name name) { return new JavaURLContext(envmt, helperServices, name); }
java
public String encodeURL(HttpSession session, String url) { return encodeURL(session, null, url, null); }
java
public void complete(VirtualConnection vc, TCPReadRequestContext rsc) { if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) { Tr.debug(tc, "complete() called: vc=" + vc); } HttpOutboundServiceContextImpl mySC = (HttpOutboundServiceContextImpl) vc.getStateMap().get(CallbackIDs.CALLBACK_HTTPOSC); mySC.continueRead(); }
java
public void error(VirtualConnection vc, TCPReadRequestContext rsc, IOException ioe) { if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) { Tr.debug(tc, "error() called: vc=" + vc + " ioe=" + ioe); } HttpOutboundServiceContextImpl mySC = (HttpOutboundServiceContextImpl) vc.getStateMap().get(CallbackIDs.CALLBACK_HTTPOSC); // Reading a body from an HTTP/1.0 server that closes the connection // after completely sending the body will trigger an IOException here. if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) { Tr.debug(tc, "Socket closure, signaling close."); } // only valid if this response is a non-length delimited body // otherwise pass the exception up to the application channel // PK18799 - check the stored SC values instead of msg as Proxy may // change it on the fly if (!mySC.isChunkedEncoding() && !mySC.isContentLength()) { mySC.prepareClosure(); mySC.getAppReadCallback().complete(vc); } else { if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) { Tr.debug(tc, "IOException during body read"); } mySC.setPersistent(false); mySC.getAppReadCallback().error(vc, ioe); } }
java
public static void logLoudAndClear(String textToLog, String callingClass, String callingMethod) { final String methodName = "logLoudAndClear"; final boolean trace = TraceComponent.isAnyTracingEnabled(); final String cClass = (callingClass != null && !callingClass.isEmpty()) ? callingClass : "callingClass"; final String cMethod = (callingMethod != null && !callingMethod.isEmpty()) ? callingMethod : "callingMethod"; if (trace && tc.isDebugEnabled()) Tr.debug(tc, "#################################################################################################" + "\n #################################################################################################" + "#################################################################################################" + "\n #################################################################################################" + "#################################################################################################" + "\n #################################################################################################" + "#################################################################################################" + "\n #################################################################################################" + "#################################################################################################" + "\n #################################################################################################" + "#################################################################################################" + "\n #################################################################################################" + "#################################################################################################" + "\n #################################################################################################" + "#################################################################################################" + "\n #################################################################################################" + "#################################################################################################" + "\n " + "\n " + cClass + ": " + cMethod + " is using " + className + ": " + methodName + " \n " + textToLog + "\n " + "\n " + "#################################################################################################" + "\n #################################################################################################" + "#################################################################################################" + "\n #################################################################################################" + "#################################################################################################" + "\n #################################################################################################" + "#################################################################################################" + "\n #################################################################################################" + "#################################################################################################" + "\n #################################################################################################" + "#################################################################################################" + "\n #################################################################################################" + "#################################################################################################" + "\n #################################################################################################" + "#################################################################################################" + "\n #################################################################################################" + "#################################################################################################"); }
java
private MessagingEngine createMessageEngine(JsMEConfig me) throws Exception { String thisMethodName = CLASS_NAME + ".createMessageEngine(JsMEConfig)"; if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) { SibTr.entry(tc, thisMethodName, "replace ME name here"); } JsMessagingEngine engineImpl = null; bus = new JsBusImpl(me, this, (me.getSIBus().getName()));// getBusProxy(me); engineImpl = new JsMessagingEngineImpl(this, bus, me); MessagingEngine engine = new MessagingEngine(me, engineImpl); _messagingEngines.put(defaultMEUUID, engine); if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) { SibTr.exit(tc, thisMethodName, engine.toString()); } return engine; }
java
private JsBusImpl getBusProxy(JsMEConfig me) { String thisMethodName = CLASS_NAME + ".getBusProxy(ConfigObject)"; if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) { SibTr.entry(tc, thisMethodName, "ME Name"); } if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) { SibTr.exit(tc, thisMethodName); } return this.bus; }
java
private JsBusImpl getBusProxy(String name) throws SIBExceptionBusNotFound { String thisMethodName = CLASS_NAME + ".getBusProxy(String)"; if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) { SibTr.entry(tc, thisMethodName, name); } if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) { SibTr.exit(tc, thisMethodName); } return this.bus; }
java
public JsBus getBus(String busName) throws SIBExceptionBusNotFound { String thisMethodName = CLASS_NAME + ".getBus(String)"; if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) { SibTr.entry(tc, thisMethodName, busName); } if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) { SibTr.exit(tc, thisMethodName); } return this.bus; }
java
public Set getMessagingEngineSet(String busName) { String thisMethodName = CLASS_NAME + ".getMessagingEngineSet(String)"; if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) { SibTr.entry(tc, thisMethodName, busName); } Set retSet = new HashSet(); if (meConfig != null) { String meName = meConfig.getMessagingEngine().getName(); BaseMessagingEngineImpl engineImpl = getMessagingEngine(meName); retSet.add(engineImpl.getUuid().toString()); } if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) { Integer i = new Integer(retSet.size()); SibTr.exit(tc, thisMethodName, i.toString()); } return retSet; }
java
public String[] showMessagingEngines() { String thisMethodName = CLASS_NAME + ".showMessagingEngines()"; if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) { SibTr.entry(tc, thisMethodName, this); } final String[] list = new String[_messagingEngines.size()]; Enumeration e = listMessagingEngines(); int i = 0; while (e.hasMoreElements()) { Object c = e.nextElement(); list[i++] = ((BaseMessagingEngineImpl) c).getBusName() + ":" + ((BaseMessagingEngineImpl) c).getName() + ":" + ((BaseMessagingEngineImpl) c).getState(); } if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) { SibTr.exit(tc, thisMethodName); } return list; }
java
public void startMessagingEngine(String busName, String name) throws Exception { String thisMethodName = CLASS_NAME + ".startMessagingEngine(String, String)"; if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) { SibTr.entry(tc, thisMethodName, new Object[] { busName, name }); } BaseMessagingEngineImpl me = (BaseMessagingEngineImpl) getMessagingEngine( busName, name); if (me != null) { me.startConditional(); } else { if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) SibTr.debug(tc, "Unable to locate engine <bus=" + busName + " name=" + name + ">"); throw new Exception("The messaging engine <bus=" + busName + " name=" + name + "> does not exist"); } if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) { SibTr.exit(tc, thisMethodName); } }
java
public boolean isServerStarted() { String thisMethodName = CLASS_NAME + ".isServerStarted()"; if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) { SibTr.entry(tc, thisMethodName, this); } if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) { SibTr.exit(tc, thisMethodName, new Boolean(_serverStarted)); } return _serverStarted; }
java
public boolean isServerStopping() { String thisMethodName = CLASS_NAME + ".isServerStopping()"; if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) { SibTr.entry(tc, thisMethodName, this); } if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) { SibTr.exit(tc, thisMethodName, new Boolean(_serverStopping)); } return _serverStopping; }
java
public boolean isServerInRecoveryMode() { String thisMethodName = CLASS_NAME + ".isServerInRecoveryMode()"; if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) { SibTr.entry(tc, thisMethodName, this); } boolean ret = false;// (_serverMode == Server.RECOVERY_MODE); TBD if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) { SibTr.exit(tc, thisMethodName, new Boolean(ret)); } return ret; }
java
public List<String> listDefinedBuses() { if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) { SibTr.entry(tc, "listDefinedBuses", this); } List buses = null; if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) { SibTr.exit(tc, "listDefinedBuses", buses); } return buses; }
java
public static final String base64Decode(String str, String enc) throws UnsupportedEncodingException { if (str == null) { return null; } else { byte data[] = getBytes(str); return base64Decode(new String(data, enc)); } }
java
public static final String base64Decode(String str) { if (str == null) { return null; } else { byte data[] = getBytes(str); return toString(base64Decode(data)); } }
java
public SIBusMessage receiveNoWait(final SITransaction tran) throws SISessionDroppedException, SIConnectionDroppedException, SISessionUnavailableException, SIConnectionUnavailableException, SIConnectionLostException, SILimitExceededException, SINotAuthorizedException, SIResourceException, SIErrorException, SIIncorrectCallException { final String methodName = "receiveNoWait"; if (TraceComponent.isAnyTracingEnabled() && TRACE.isEntryEnabled()) { SibTr.entry(this, TRACE, methodName, tran); } checkValid(); final SIBusMessage message = _delegate.receiveNoWait(_parentConnection .mapTransaction(tran)); if (TraceComponent.isAnyTracingEnabled() && TRACE.isEntryEnabled()) { SibTr.exit(this, TRACE, methodName, message); } return message; }
java
public void start(boolean deliverImmediately) throws SIConnectionDroppedException, SISessionUnavailableException, SIConnectionUnavailableException, SIConnectionLostException, SIResourceException, SIErrorException, SIErrorException { final String methodName = "start"; if (TraceComponent.isAnyTracingEnabled() && TRACE.isEntryEnabled()) { SibTr.entry(this, TRACE, methodName, Boolean .valueOf(deliverImmediately)); } checkValid(); _delegate.start(deliverImmediately); if (TraceComponent.isAnyTracingEnabled() && TRACE.isEntryEnabled()) { SibTr.exit(this, TRACE, methodName); } }
java
public void stop() throws SISessionDroppedException, SIConnectionDroppedException, SISessionUnavailableException, SIConnectionUnavailableException, SIConnectionLostException, SIResourceException, SIErrorException { final String methodName = "stop"; if (TraceComponent.isAnyTracingEnabled() && TRACE.isEntryEnabled()) { SibTr.entry(this, TRACE, methodName); } checkValid(); _delegate.stop(); if (TraceComponent.isAnyTracingEnabled() && TRACE.isEntryEnabled()) { SibTr.exit(this, TRACE, methodName); } }
java
@Override public void unlockAll(boolean incrementUnlockCount) throws SISessionUnavailableException, SISessionDroppedException, SIConnectionUnavailableException, SIConnectionDroppedException, SIResourceException, SIConnectionLostException, SIIncorrectCallException { throw new SibRaNotSupportedException(NLS .getString("ASYNCHRONOUS_METHOD_CWSIV0250")); }
java
public void setConnectionObjectID(int i) { if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(this, tc, "setConnectionObjectID", ""+i); connectionObjectID = i; if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(this, tc, "setConnectionObjectID"); }
java
public ProxyQueueConversationGroup getProxyQueueConversationGroup() { if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(this, tc, "getProxyQueueConversationGroup"); if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(this, tc, "getProxyQueueConversationGroup", proxyGroup); return proxyGroup; }
java
public CatConnectionListenerGroup getCatConnectionListeners() { if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(this, tc, "getCatConnectionListeners"); if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(this, tc, "getCatConnectionListeners", catConnectionGroup); return catConnectionGroup; }
java
public SICoreConnection getSICoreConnection() { if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(this, tc, "getSICoreConnection"); if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(this, tc, "getSICoreConnection", siCoreConnection); return siCoreConnection; }
java
public final boolean unlink() { if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(this, tc, "unlink", _positionString()); if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) SibTr.debug(this, tc, "cursor count = " + _cursorCount); boolean unlinked = false; LinkedList parent = _parent; if (null != parent) { synchronized(parent) { if (LinkState.LINKED == _state) { _state = LinkState.LOGICALLY_UNLINKED; _tryUnlink(); unlinked = true; } else { if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) SibTr.debug(this, tc, "unlink while " + _state); } } } if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(this, tc, "unlink", new Object[] { Boolean.valueOf(unlinked), _positionString()}); return unlinked; }
java
private boolean isRequestForbidden(StringBuffer path) { boolean requestIsForbidden = false; String matchString = path.toString(); //PM82876 Start // The fileName or dirName can have .. , check and fail for ".." in path only which can allow to serve from different location. if(WCCustomProperties.ALLOW_DOTS_IN_NAME){ if (matchString.indexOf("..") > -1) { if( (matchString.indexOf("/../") > -1) || (matchString.indexOf("\\..\\") > -1) || matchString.startsWith("../") || matchString.endsWith("/..") || matchString.startsWith("..\\")|| matchString.endsWith("\\..")) { requestIsForbidden = true; if (com.ibm.ejs.ras.TraceComponent.isAnyTracingEnabled() && logger.isLoggable(Level.FINE)) logger.logp(Level.FINE, CLASS_NAME, "isRequestForbidden", "bad path :" + matchString); } } if ((!requestIsForbidden && (matchString.endsWith("\\") || matchString.endsWith(".") || matchString.endsWith("/")))) { requestIsForbidden = true; } } else{ //PM82876 End /** * Do not allow ".." to appear in a path as it allows one to serve files from anywhere within * the file system. * Also check to see if the path or URI ends with '/', '\', or '.' . * PQ44346 - Allow files on DFS to be served. */ if ((matchString.lastIndexOf("..") != -1 && (!matchString.startsWith("/..."))) || matchString.endsWith("\\") // PK23475 use matchString instead of RequestURI because RequestURI is not decoded // || req.getRequestURI().endsWith(".") || matchString.endsWith(".") // PK22928 // || req.getRequestURI().endsWith("/")){ || matchString.endsWith("/")) //PK22928 { requestIsForbidden = true; } } if (com.ibm.ejs.ras.TraceComponent.isAnyTracingEnabled()&&logger.isLoggable (Level.FINE)) logger.logp(Level.FINE, CLASS_NAME,"isRequestForbidden","returning :" + requestIsForbidden + ", matchstring :" + matchString); return requestIsForbidden; }
java
private boolean isDirectoryTraverse(StringBuffer path) { boolean directoryTraverse = false; String matchString = path.toString(); //PM82876 Start if (WCCustomProperties.ALLOW_DOTS_IN_NAME) { // The fileName can have .. , check for the failing conditions only. if (matchString.indexOf("..") > -1) { if( (matchString.indexOf("/../") > -1) || (matchString.indexOf("\\..\\") > -1) || matchString.startsWith("../") || matchString.endsWith("/..") || matchString.startsWith("..\\")|| matchString.endsWith("\\..")) { directoryTraverse = true; if (com.ibm.ejs.ras.TraceComponent.isAnyTracingEnabled() && logger.isLoggable(Level.FINE)) logger.logp(Level.FINE, CLASS_NAME, "isDirectoryTraverse", "bad path :" + matchString); } } } else{//PM82876 End /** * Do not allow ".." to appear in a path as it allows one to serve files from anywhere within * the file system. * Also check to see if the path or URI ends with '/', '\', or '.' . * PQ44346 - Allow files on DFS to be served. */ if ( (matchString.lastIndexOf("..") != -1) && (!matchString.startsWith("/...") )) { directoryTraverse = true; } } if (com.ibm.ejs.ras.TraceComponent.isAnyTracingEnabled()&&logger.isLoggable (Level.FINE)) logger.logp(Level.FINE, CLASS_NAME,"isDirectoryTraverse", "returning" + directoryTraverse + " , matchstring :" + matchString); return directoryTraverse; }
java
public ServiceRegistration<FileMonitor> monitorFiles(Collection<String> paths, long monitorInterval) { BundleContext bundleContext = actionable.getBundleContext(); final Hashtable<String, Object> fileMonitorProps = new Hashtable<String, Object>(); fileMonitorProps.put(FileMonitor.MONITOR_FILES, paths); fileMonitorProps.put(FileMonitor.MONITOR_INTERVAL, monitorInterval); return bundleContext.registerService(FileMonitor.class, this, fileMonitorProps); }
java
public ServiceRegistration<FileMonitor> monitorFiles(String ID, Collection<String> paths, long pollingRate, String trigger) { BundleContext bundleContext = actionable.getBundleContext(); final Hashtable<String, Object> fileMonitorProps = new Hashtable<String, Object>(); fileMonitorProps.put(FileMonitor.MONITOR_FILES, paths); //Adding INTERNAL parameter MONITOR_IDENTIFICATION_NAME to identify this monitor. fileMonitorProps.put(com.ibm.ws.kernel.filemonitor.FileMonitor.MONITOR_IDENTIFICATION_NAME, com.ibm.ws.kernel.filemonitor.FileMonitor.SECURITY_MONITOR_IDENTIFICATION_VALUE); //Adding parameter MONITOR_IDENTIFICATION_CONFIG_ID to identify this monitor by the ID. fileMonitorProps.put(com.ibm.ws.kernel.filemonitor.FileMonitor.MONITOR_KEYSTORE_CONFIG_ID, ID); if (!(trigger.equalsIgnoreCase("disabled"))) { if (trigger.equals("mbean")) { fileMonitorProps.put(FileMonitor.MONITOR_TYPE, FileMonitor.MONITOR_TYPE_EXTERNAL); } else { fileMonitorProps.put(FileMonitor.MONITOR_TYPE, FileMonitor.MONITOR_TYPE_TIMED); fileMonitorProps.put(FileMonitor.MONITOR_INTERVAL, pollingRate); } } // Don't attempt to register the file monitor if the server is stopping if (FrameworkState.isStopping()) return null; return bundleContext.registerService(FileMonitor.class, this, fileMonitorProps); }
java
private Boolean isActionNeeded(Collection<File> createdFiles, Collection<File> modifiedFiles) { boolean actionNeeded = false; for (File createdFile : createdFiles) { if (currentlyDeletedFiles.contains(createdFile)) { currentlyDeletedFiles.remove(createdFile); actionNeeded = true; } } if (modifiedFiles.isEmpty() == false) { actionNeeded = true; } return actionNeeded; }
java
public QueuedMessage[] getQueuedMessages(java.lang.Integer fromIndexInteger,java.lang.Integer toIndexInteger,java.lang.Integer totalMessagesPerpageInteger) throws Exception { int fromIndex=fromIndexInteger.intValue(); int toIndex=toIndexInteger.intValue(); int totalMessagesPerpage=totalMessagesPerpageInteger.intValue(); if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(tc, "getQueuedMessages fromIndex="+fromIndex+" toIndex= "+toIndex+" totalMsgs= "+totalMessagesPerpage); List list = new ArrayList(); Iterator iter = _c.getQueuedMessageIterator(fromIndex,toIndex,totalMessagesPerpage);//673411 while (iter != null && iter.hasNext()) { SIMPQueuedMessageControllable o = (SIMPQueuedMessageControllable) iter.next(); list.add(o); } List resultList = new ArrayList(); iter = list.iterator(); int i = 0; while (iter.hasNext()) { Object o = iter.next(); QueuedMessage qm = SIBMBeanResultFactory.createSIBQueuedMessage((SIMPQueuedMessageControllable) o); resultList.add(qm); } QueuedMessage[] retValue = (QueuedMessage[])resultList.toArray(new QueuedMessage[0]); if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(tc, "getQueuedMessagesfromIndex="+fromIndex+" toIndex= "+toIndex+" totalMsgs= "+totalMessagesPerpage, retValue); return retValue; }
java
private void initializeCacheData(int cacheSize) { final boolean isTraceOn = TraceComponent.isAnyTracingEnabled(); if (isTraceOn && (tc.isEntryEnabled() || tcOOM.isEntryEnabled())) Tr.entry(tc.isEntryEnabled() ? tc : tcOOM, "initializeCacheData : " + ivCache.getName() + " preferred size = " + ivPreferredMaxSize); ivPreferredMaxSize = cacheSize; // Define an internal upper limit to the cache size. This is similar // to the 'hard' limit, but would never be enforced; it is merely // used to determine a point at which the eviction strategy should // dynamically tune itself to become more aggressive. d112258 ivUpperLimit = (long) (ivPreferredMaxSize * 1.1); // 10% over cache size // Give the cache a little breathing room (or buffer) below the // soft limit. By reducing to this far below the soft limit, it // is less likely that the next sweep will have to do anything. ivSoftLimitBuffer = ivPreferredMaxSize / 100; // 1% of the Cache Size if (ivSoftLimitBuffer > 50) // Don't let this get too big. ivSoftLimitBuffer = 50; if (isTraceOn && (tc.isEntryEnabled() || tcOOM.isEntryEnabled())) Tr.exit(tc.isEntryEnabled() ? tc : tcOOM, "initializeCacheData : " + ivCache.getName() + " preferred size = " + ivPreferredMaxSize + " limit = " + ivUpperLimit + ", buffer = " + ivSoftLimitBuffer); }
java
private void initializeSweepInterval(long sweepInterval) { final boolean isTraceOn = TraceComponent.isAnyTracingEnabled(); if (isTraceOn && (tc.isEntryEnabled() || tcOOM.isEntryEnabled())) Tr.entry(tc.isEntryEnabled() ? tc : tcOOM, "initializeSweepInterval : " + ivCache.getName() + " preferred size = " + ivPreferredMaxSize + ", sweep = " + sweepInterval); ivSweepInterval = sweepInterval; // Adjust the discard threshold according to the sweepInterval. // The discard threshold is a value between 2 and 20. d112258 if ((ivSweepInterval * ivDiscardThreshold) > MAX_THRESHOLD_MULTIPLIER) { ivDiscardThreshold = (MAX_THRESHOLD_MULTIPLIER / ivSweepInterval); if (ivDiscardThreshold < 2) ivDiscardThreshold = 2; } // Determine the upper and lower bounds for the discard threshold for // dynamic tuning of the eviction strategy. The max threshold will allow // objects to age for up to 1 minute (MAX_THRESHOLD_MULTIPLIER), and // the min threshold requires that objects age for at least 9 seconds // (MIN_THRESHOLD_MULTIPLIER). d112258 ivMaxDiscardThreshold = ivDiscardThreshold; ivMinDiscardThreshold = (MIN_THRESHOLD_MULTIPLIER / ivSweepInterval); if (ivMinDiscardThreshold < 2) ivMinDiscardThreshold = 2; if (isTraceOn && (tc.isEntryEnabled() || tcOOM.isEntryEnabled())) Tr.exit(tc.isEntryEnabled() ? tc : tcOOM, "initializeSweepInterval : " + ivCache.getName() + " preferred size = " + ivPreferredMaxSize + ", sweep = " + ivSweepInterval + ", threshold = " + ivDiscardThreshold + ", buffer = " + ivSoftLimitBuffer); }
java
private boolean isTraceEnabled(boolean debug) // d581579 { if (debug ? tc.isDebugEnabled() : tc.isEntryEnabled()) { return true; } if (ivCache.numSweeps % NUM_SWEEPS_PER_OOMTRACE == 1 && (debug ? tcOOM.isDebugEnabled() : tcOOM.isEntryEnabled())) { return true; } return false; }
java
protected NetworkConnection getNetworkConnectionInstance(VirtualConnection vc) { if (tc.isEntryEnabled()) SibTr.entry(this, tc, "getNetworkConnectionInstance", vc); NetworkConnection retConn = null; if (vc != null) { // Default to the connection that we were created from retConn = conn; if (vc != ((CFWNetworkConnection) conn).getVirtualConnection()) { // The connection is different - nothing else to do but create a new instance retConn = new CFWNetworkConnection(vc); } } if (tc.isEntryEnabled()) SibTr.exit(this, tc, "getNetworkConnectionInstance", retConn); return retConn; }
java
private void setChoices(BigInteger multiChoice, JSchema schema) { JSType topType = (JSType)schema.getJMFType(); if (topType instanceof JSVariant) setChoices(multiChoice, schema, (JSVariant)topType); else if (topType instanceof JSTuple) setChoices( multiChoice, topType.getMultiChoiceCount(), schema, ((JSTuple)topType).getDominatedVariants()); else // If topType is JSRepeated, JSDynamic, JSEnum, or JSPrimitive there can be no unboxed // variants at top level. return; }
java
private void setChoices(BigInteger multiChoice, JSchema schema, JSVariant var) { for (int i = 0; i < var.getCaseCount(); i++) { BigInteger count = ((JSType)var.getCase(i)).getMultiChoiceCount(); if (multiChoice.compareTo(count) >= 0) multiChoice = multiChoice.subtract(count); else { // We now have the case of our particular Variant in i. We set that in // choiceCodes and then recursively visit the Variants dominated by ours. choiceCodes[var.getIndex()] = i; JSVariant[] subVars = var.getDominatedVariants(i); setChoices(multiChoice, count, schema, subVars); return; } } // We should never get here throw new RuntimeException("Bad multiChoice code"); }
java
private void setChoices(BigInteger multiChoice, BigInteger radix, JSchema schema, JSVariant[] vars) { for (int j = 0; j < vars.length; j++) { radix = radix.divide(vars[j].getMultiChoiceCount()); BigInteger contrib = multiChoice.divide(radix); multiChoice = multiChoice.remainder(radix); setChoices(contrib, schema, vars[j]); } }
java
private static BigInteger getMultiChoice(int[] choices, JSchema schema, JSVariant var) throws JMFUninitializedAccessException { int choice = choices[var.getIndex()]; if (choice == -1) throw new JMFUninitializedAccessException(schema.getPathName(var)); BigInteger ans = BigInteger.ZERO; // First, add the contribution of the cases less than the present one. for (int i = 0; i < choice; i++) ans = ans.add(((JSType)var.getCase(i)).getMultiChoiceCount()); // Now compute the contribution of the actual case. Get the subvariants dominated by // this variant's present case. JSVariant[] subVars = var.getDominatedVariants(choice); if (subVars == null) // There are none: we already have the answer return ans; return ans.add(getMultiChoice(choices, schema, subVars)); }
java
private static BigInteger getMultiChoice(int[] choices, JSchema schema, JSVariant[] vars) throws JMFUninitializedAccessException { // Mixed-radix-encode the contribution from all the subvariants BigInteger base = BigInteger.ZERO; for (int i = 0; i < vars.length; i++) base = base.multiply(vars[i].getMultiChoiceCount()).add(getMultiChoice(choices, schema, vars[i])); return base; }
java
protected String getStyle(FacesContext facesContext, UIComponent link) { if (link instanceof HtmlCommandLink) { return ((HtmlCommandLink)link).getStyle(); } return (String)link.getAttributes().get(HTML.STYLE_ATTR); }
java
protected String getStyleClass(FacesContext facesContext, UIComponent link) { if (link instanceof HtmlCommandLink) { return ((HtmlCommandLink)link).getStyleClass(); } return (String)link.getAttributes().get(HTML.STYLE_CLASS_ATTR); }
java
protected void completeConnectionPreface() throws Http2Exception { if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) { Tr.debug(tc, "completeConnectionPreface entry: about to send preface SETTINGS frame"); } FrameSettings settings; // send out a settings frame with any HTTP2 settings that the user may have changed if (Constants.SPEC_INITIAL_WINDOW_SIZE != this.streamReadWindowSize) { settings = new FrameSettings(0, -1, -1, this.muxLink.config.getH2MaxConcurrentStreams(), (int) this.streamReadWindowSize, this.muxLink.config.getH2MaxFrameSize(), -1, false); } else { settings = new FrameSettings(0, -1, -1, this.muxLink.config.getH2MaxConcurrentStreams(), -1, this.muxLink.config.getH2MaxFrameSize(), -1, false); } this.frameType = FrameTypes.SETTINGS; this.processNextFrame(settings, Direction.WRITING_OUT); if (Constants.SPEC_INITIAL_WINDOW_SIZE != muxLink.maxReadWindowSize) { // the user has changed the max connection read window, so we'll update that now FrameWindowUpdate wup = new FrameWindowUpdate(0, (int) muxLink.maxReadWindowSize, false); this.processNextFrame(wup, Direction.WRITING_OUT); } }
java
private void readWriteTransitionState(Constants.Direction direction) throws Http2Exception { if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) { Tr.debug(tc, "readWriteTransitionState: entry: frame type: " + currentFrame.getFrameType() + " state: " + state); } if (currentFrame.getFrameType() == FrameTypes.GOAWAY || currentFrame.getFrameType() == FrameTypes.RST_STREAM) { writeFrameSync(); rstStreamSent = true; this.updateStreamState(StreamState.CLOSED); if (currentFrame.getFrameType() == FrameTypes.GOAWAY) { muxLink.closeConnectionLink(null); } if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) { Tr.debug(tc, "readWriteTransitionState: return: state: " + state); } return; } switch (state) { case IDLE: processIdle(direction); break; case RESERVED_LOCAL: processReservedLocal(direction); break; case RESERVED_REMOTE: processReservedRemote(direction); break; case OPEN: processOpen(direction); break; case HALF_CLOSED_REMOTE: processHalfClosedRemote(direction); break; case HALF_CLOSED_LOCAL: processHalfClosedLocal(direction); break; case CLOSED: processClosed(direction); break; default: break; } if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) { Tr.debug(tc, "readWriteTransitionState: exit: state: " + state); } }
java
private void updateStreamState(StreamState state) { this.state = state; if (StreamState.CLOSED.equals(state)) { setCloseTime(System.currentTimeMillis()); muxLink.closeStream(this); } if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) { Tr.debug(tc, "current stream state for stream " + this.myID + " : " + this.state); } }
java
private void processSETTINGSFrame() throws FlowControlException { if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) { Tr.debug(tc, "processSETTINGSFrame entry:\n" + currentFrame.toString()); } // check if this is the first non-ACK settings frame received; if so, update connection init state if (!connection_preface_settings_rcvd && !((FrameSettings) currentFrame).flagAckSet()) { connection_preface_settings_rcvd = true; } if (((FrameSettings) currentFrame).flagAckSet()) { // if this is the first ACK frame, update connection init state if (!connection_preface_settings_ack_rcvd) { connection_preface_settings_ack_rcvd = true; } } else { if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) { Tr.debug(tc, "received a new settings frame: updating connection settings and sending out SETTINGS ACK"); } // if the INITIAL_WINDOW_SIZE has changed, need to change it for this streams, and all the other streams on this connection if (((FrameSettings) currentFrame).getInitialWindowSize() != -1) { int newSize = ((FrameSettings) currentFrame).getInitialWindowSize(); muxLink.changeInitialWindowSizeAllStreams(newSize); } // update the SETTINGS for this connection muxLink.getRemoteConnectionSettings().updateSettings((FrameSettings) currentFrame); muxLink.getVirtualConnection().getStateMap().put("h2_frame_size", muxLink.getRemoteConnectionSettings().getMaxFrameSize()); // immediately send out ACK (an empty SETTINGS frame with the ACK flag set) currentFrame = new FrameSettings(0, -1, -1, -1, -1, -1, -1, false); currentFrame.setAckFlag(); try { if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) { Tr.debug(tc, "processSETTINGSFrame: stream: " + myID + " frame type: " + currentFrame.getFrameType().toString() + " direction: " + Direction.WRITING_OUT + " H2InboundLink hc: " + muxLink.hashCode()); } writeFrameSync(); } catch (FlowControlException e) { // FlowControlException cannot occur for FrameTypes.SETTINGS, so do nothing here but debug if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) { Tr.debug(tc, "writeSync caught (logically unexpected) FlowControlException: " + e); } } } // check to see if the current connection should be marked as initialized; if so, notify stream 1 to stop waiting if (connection_preface_settings_rcvd && connection_preface_settings_ack_rcvd) { if (muxLink.checkInitAndOpen()) { muxLink.initLock.countDown(); } } }
java
private void updateStreamReadWindow() throws Http2Exception { if (currentFrame instanceof FrameData) { long frameSize = currentFrame.getPayloadLength(); streamReadWindowSize -= frameSize; // decrement stream read window muxLink.connectionReadWindowSize -= frameSize; // decrement connection read window // if the stream or connection windows become too small, update the windows // TODO: decide how often we should update the read window via WINDOW_UPDATE if (streamReadWindowSize < (muxLink.maxReadWindowSize / 2) || muxLink.connectionReadWindowSize < (muxLink.maxReadWindowSize / 2)) { int windowChange = (int) (muxLink.maxReadWindowSize - this.streamReadWindowSize); Frame savedFrame = currentFrame; // save off the current frame if (!this.isStreamClosed()) { currentFrame = new FrameWindowUpdate(myID, windowChange, false); writeFrameSync(); currentFrame = savedFrame; } long windowSizeIncrement = muxLink.getRemoteConnectionSettings().getMaxFrameSize(); FrameWindowUpdate wuf = new FrameWindowUpdate(0, (int) windowSizeIncrement, false); this.muxLink.getStream(0).processNextFrame(wuf, Direction.WRITING_OUT); } } }
java
protected void updateInitialWindowsUpdateSize(int newSize) throws FlowControlException { // this method should only be called by the thread that came in on processNewFrame. // newSize should be treated as an unsigned 32-bit int if (myID == 0) { // the control stream doesn't care about initial window size updates return; } if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) { Tr.debug(tc, "updateInitialWindowsUpdateSize entry: stream {0} newSize: {1}", myID, newSize); } long diff = newSize - streamWindowUpdateWriteInitialSize; streamWindowUpdateWriteInitialSize = newSize; streamWindowUpdateWriteLimit += diff; if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) { Tr.debug(tc, "streamWindowUpdateWriteInitialSize updated to: " + streamWindowUpdateWriteInitialSize); Tr.debug(tc, "streamWindowUpdateWriteLimit updated to: " + streamWindowUpdateWriteLimit); } // if any data frames were waiting for a window update, write them out now flushDataWaitingForWindowUpdate(); }
java
private void processIdle(Constants.Direction direction) throws Http2Exception { if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) { Tr.debug(tc, "processIdle entry: stream " + myID); } // Can only receive HEADERS or PRIORITY frame in Idle state if (direction == Constants.Direction.READ_IN) { if (frameType == FrameTypes.HEADERS) { // check to see if too many client streams are currently open for this stream's h2 connection muxLink.incrementActiveClientStreams(); if (muxLink.getActiveClientStreams() > muxLink.getLocalConnectionSettings().getMaxConcurrentStreams()) { RefusedStreamException rse = new RefusedStreamException("too many client-initiated streams are currently active; rejecting this stream"); rse.setConnectionError(false); throw rse; } processHeadersPriority(); getHeadersFromFrame(); if (currentFrame.flagEndHeadersSet()) { processCompleteHeaders(false); setHeadersComplete(); } else { muxLink.setContinuationExpected(true); } if (currentFrame.flagEndStreamSet()) { endStream = true; updateStreamState(StreamState.HALF_CLOSED_REMOTE); if (currentFrame.flagEndHeadersSet()) { setReadyForRead(); } } else { updateStreamState(StreamState.OPEN); } } } else { // send out a HEADER frame and update the stream state to OPEN if (frameType == FrameTypes.HEADERS) { updateStreamState(StreamState.OPEN); } writeFrameSync(); } }
java
private boolean isWindowLimitExceeded(FrameData dataFrame) { if (streamWindowUpdateWriteLimit - dataFrame.getPayloadLength() < 0 || muxLink.getWorkQ().getConnectionWriteLimit() - dataFrame.getPayloadLength() < 0) { // would exceed window update limit String s = "Cannot write Data Frame because it would exceed the stream window update limit." + "streamWindowUpdateWriteLimit: " + streamWindowUpdateWriteLimit + "\nstreamWindowUpdateWriteInitialSize: " + streamWindowUpdateWriteInitialSize + "\nconnection window size: " + muxLink.getWorkQ().getConnectionWriteLimit() + "\nframe size: " + dataFrame.getPayloadLength(); if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) { Tr.debug(tc, s); } return true; } return false; }
java
public void sendRequestToWc(FramePPHeaders frame) { if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) { Tr.entry(tc, "H2StreamProcessor.sendRequestToWc()"); } if (null == frame) { if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) { Tr.debug(tc, "H2StreamProcessor.sendRequestToWc(): Frame is null"); } } else { // Make the headers frame look like it just came in WsByteBuffer buf = frame.buildFrameForWrite(); TCPReadRequestContext readi = h2HttpInboundLinkWrap.getConnectionContext().getReadInterface(); readi.setBuffer(buf); // Call the synchronized method to handle the frame try { processNextFrame(frame, Constants.Direction.READ_IN); } catch (Http2Exception he) { // ProcessNextFrame() sends a reset/goaway if an error occurs, nothing left but to clean up if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) { Tr.debug(tc, "H2StreamProcessor.sendRequestToWc(): ProcessNextFrame() error, Exception: " + he); } // Free the buffer buf.release(); } } if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) { Tr.exit(tc, "H2StreamProcessor.sendRequestToWc()"); } }
java
private void setHeadersComplete() { if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) { Tr.debug(tc, "completed headers have been received stream " + myID); } headersCompleted = true; muxLink.setContinuationExpected(false); }
java
private void getHeadersFromFrame() { byte[] hbf = null; if (currentFrame.getFrameType() == FrameTypes.HEADERS || currentFrame.getFrameType() == FrameTypes.PUSHPROMISEHEADERS) { hbf = ((FrameHeaders) currentFrame).getHeaderBlockFragment(); } else if (currentFrame.getFrameType() == FrameTypes.CONTINUATION) { hbf = ((FrameContinuation) currentFrame).getHeaderBlockFragment(); } if (hbf != null) { if (headerBlock == null) { headerBlock = new ArrayList<byte[]>(); } headerBlock.add(hbf); } }
java
private void getBodyFromFrame() { if (dataPayload == null) { dataPayload = new ArrayList<byte[]>(); } if (currentFrame.getFrameType() == FrameTypes.DATA) { dataPayload.add(((FrameData) currentFrame).getData()); } }
java
private void processCompleteData() throws ProtocolException { WsByteBufferPoolManager bufManager = HttpDispatcher.getBufferManager(); WsByteBuffer buf = bufManager.allocate(getByteCount(dataPayload)); for (byte[] bytes : dataPayload) { buf.put(bytes); } buf.flip(); if (expectedContentLength != -1 && buf.limit() != expectedContentLength) { if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) { Tr.debug(tc, "processCompleteData release buffer and throw ProtocolException"); } buf.release(); ProtocolException pe = new ProtocolException("content-length header did not match the expected amount of data received"); pe.setConnectionError(false); // stream error throw pe; } moveDataIntoReadBufferArray(buf); }
java
private void setReadyForRead() throws ProtocolException { if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) { Tr.debug(tc, "setReadyForRead entry: stream id:" + myID); } muxLink.updateHighestStreamId(myID); if (headersCompleted) { ExecutorService executorService = CHFWBundle.getExecutorService(); Http2Ready readyThread = new Http2Ready(h2HttpInboundLinkWrap); executorService.execute(readyThread); } }
java
private void moveDataIntoReadBufferArray(WsByteBuffer newReadBuffer) { if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) { Tr.debug(tc, "moveDataIntoReadBufferArray entry: stream " + myID + " buffer: " + newReadBuffer); } // move the data that is to be sent up the channel into the currentReadReady byte array, and update the currentReadSize if (newReadBuffer != null) { int size = newReadBuffer.remaining(); // limit - pos if (size > 0) { streamReadReady.add(newReadBuffer); streamReadSize += size; this.readLatch.countDown(); } } }
java
@SuppressWarnings("unchecked") public VirtualConnection read(long numBytes, WsByteBuffer[] requestBuffers) { if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) { Tr.debug(tc, "read entry: stream " + myID + " request: " + requestBuffers + " num bytes requested: " + numBytes); } long streamByteCount = streamReadSize; // number of bytes available on this stream long requestByteCount = bytesRemaining(requestBuffers); // total capacity of the caller byte array int reqArrayIndex = 0; // keep track of where we are in the caller's array // if at least numBytes are ready to be processed as part of the HTTP Request/Response, then load it up if (numBytes > streamReadSize || requestBuffers == null) { if (this.headersCompleted) { return h2HttpInboundLinkWrap.getVirtualConnection(); } else { if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) { Tr.debug(tc, "read exit: stream " + myID + " more bytes requested than available for read: " + numBytes + " > " + streamReadSize); } return null; } } if (streamByteCount < requestByteCount) { // the byte count requested exceeds the caller array capacity actualReadCount = streamByteCount; } else { actualReadCount = requestByteCount; } // copy bytes from this stream into the caller arrays for (int bytesRead = 0; bytesRead < actualReadCount; bytesRead++) { // find the first buffer from the caller that has remaining capacity while ((requestBuffers[reqArrayIndex].position() == requestBuffers[reqArrayIndex].limit())) { reqArrayIndex++; } // find the next stream buffer that has data while (!streamReadReady.isEmpty() && !streamReadReady.get(0).hasRemaining()) { streamReadReady.get(0).release(); streamReadReady.remove(0); } requestBuffers[reqArrayIndex].put(streamReadReady.get(0).get()); } // put stream array back in shape streamReadSize = 0; readLatch = new CountDownLatch(1); for (WsByteBuffer buffer : ((ArrayList<WsByteBuffer>) streamReadReady.clone())) { streamReadReady.clear(); if (buffer.hasRemaining()) { moveDataIntoReadBufferArray(buffer.slice()); } } if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) { Tr.debug(tc, "read exit: " + streamId()); } // return the vc since this was a successful read return h2HttpInboundLinkWrap.getVirtualConnection(); }
java
public boolean isStreamClosed() { if (this.myID == 0 && !endStream) { return false; } if (state == StreamState.CLOSED) { if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) { Tr.debug(tc, "isStreamClosed stream closed; " + streamId()); } return true; } boolean rc = muxLink.checkIfGoAwaySendingOrClosing(); if (rc == true) { if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) { Tr.debug(tc, "isStreamClosed stream closed via muxLink check; " + streamId()); } } return rc; }
java
private int getByteCount(ArrayList<byte[]> listOfByteArrays) { int count = 0; for (byte[] byteArray : listOfByteArrays) { if (byteArray != null) { count += byteArray.length; } } return count; }
java
public static String generateIncUuid(Object caller) { if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(tc, "generateIncUuid", "Caller="+caller); java.util.Date time = new java.util.Date(); int hash = caller.hashCode(); long millis = time.getTime(); byte[] data = new byte[] {(byte)(hash>>24), (byte)(hash>>16), (byte)(hash>>8), (byte)(hash), (byte)(millis>>24), (byte)(millis>>16), (byte)(millis>>8), (byte)(millis)}; String digits = "0123456789ABCDEF"; StringBuffer retval = new StringBuffer(data.length*2); for (int i = 0; i < data.length; i++) { retval.append(digits.charAt((data[i] >> 4) & 0xf)); retval.append(digits.charAt(data[i] & 0xf)); } if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(tc, "generateIncUuid", "return="+retval); return retval.toString(); }
java
public static String getMEName(Object o) { String meName; if (!threadLocalStack.isEmpty()) { meName = threadLocalStack.peek(); } else { meName = DEFAULT_ME_NAME; } String str = ""; if (o != null) { str = "/" + Integer.toHexString(System.identityHashCode(o)); } // Defect 91793 to avoid SIBMessage in Systemout.log starting with [:] return ""; }
java