@Override protected boolean onAccessDenied(ServletRequest request, ServletResponse response) throws Exception { if (isLoginRequest(request, response)) { if (isLoginSubmission(request, response)) { if (logger.isTraceEnabled()) { logger.trace("Login submission detected. Attempting to execute login."); } return executeLogin(request, response); } else { if (logger.isTraceEnabled()) { logger.trace("Login page view."); } // allow them to see the login page ;) return true; } } else { if (logger.isTraceEnabled()) { logger.trace( "Attempting to access a path which requires authentication. Forwarding to the " + "Authentication url [" + getLoginUrl() + "]"); } if (isMobileAppAccess(request)) { HttpServletResponse httpServletResponse = (HttpServletResponse) response; httpServletResponse.setStatus(HttpStatus.UNAUTHORIZED.value()); return true; } else { saveRequestAndRedirectToLogin(request, response); return false; } } }
/** * Parses supplied filterPattern. If it contains any qualifiers like %and&|%or% parses them into * valid regex representation. * * @param val pattern String */ protected void extractPatternParts(String val) { String qRegex = ""; for (Qualifier it : Qualifier.values()) { qRegex += qRegex.length() > 0 ? "|%" + it + "%" : "%" + it + "%"; } if (LOGGER.isTraceEnabled()) LOGGER.trace("Trying to match supplied pattern /{}/ if it contains /{}/", val, qRegex); Matcher qualifierMatcher = Pattern.compile(qRegex).matcher(val); // matching any qualifiers with % signs if (qualifierMatcher.find()) { if (LOGGER.isTraceEnabled()) LOGGER.trace("Processing extended pattern"); String[] tokens = val.split("%"); String nextQualifier = null; if (tokens != null) { qRegex = qRegex.replaceAll("%", ""); // matching only qualifier names for (String grp : tokens) { if (LOGGER.isTraceEnabled()) LOGGER.trace("Next group in match: {}", grp); qualifierMatcher = Pattern.compile(qRegex).matcher(grp); if (qualifierMatcher.matches()) { nextQualifier = qualifierMatcher.group(); continue; } addExtendedFilterPattern(grp, nextQualifier); nextQualifier = null; } } else throw new IllegalArgumentException("Check your extended pattern:/" + val + "/"); } else { if (LOGGER.isTraceEnabled()) LOGGER.trace("No extended pattern supplied; keeping things simple"); patternBuilder.append(val); } }
/** * Send message * * @param message The message * @param deliveryMode The delivery mode * @param priority The priority * @param timeToLive The time to live * @exception JMSException Thrown if an error occurs */ public void send( final Message message, final int deliveryMode, final int priority, final long timeToLive) throws JMSException { _session.lock(); try { if (_log.isTraceEnabled()) { _log.trace( "send " + this + " message=" + Util.asString(message) + " deliveryMode=" + deliveryMode + " priority=" + priority + " ttl=" + timeToLive); } checkState(); _producer.send(message, deliveryMode, priority, timeToLive); if (_log.isTraceEnabled()) { _log.trace("sent " + this + " result=" + Util.asString(message)); } } finally { _session.unlock(); } }
private void browseDir(ModelImpl model, File requestedFile) throws IOException { if (logger.isTraceEnabled()) logger.trace("> browseDir {}", requestedFile.getAbsolutePath()); model.put("app", this); Map files = new HashMap(); model.put("files", files); for (File file : requestedFile.listFiles()) { files.put( file.getName(), new Object[] { file, FileUtils.byteCountToDisplaySize(file.length()), DateTimeUtil.timestampForDisplay(file.lastModified()) }); } File indexFile = new File(requestedFile, "index.html"); String selectedTemplate; if (indexFile.exists()) { selectedTemplate = FileUtils.readFileToString(indexFile); } else { selectedTemplate = dirTemplate; } String dirPage = StringTemplateUtils.render(selectedTemplate, model); model.getResponse().getWriter().println(dirPage); if (logger.isTraceEnabled()) logger.trace("< browseDir"); }
private static void addEntry(final ZipOutputStream zos, final File file, final int bufferSize) throws IOException { if (log.isTraceEnabled()) log.trace(HelperLog.methodStart(zos, file, bufferSize)); final byte[] buffer = new byte[bufferSize]; // create a new zip entry final ZipEntry entry = new ZipEntry( file.getPath() + (file.isDirectory() ? "/" : HelperString.EMPTY_STRING)); // $NON-NLS-1$ // place the zip entry in the ZipOutputStream object zos.putNextEntry(entry); if (!file.isDirectory()) { try (BufferedInputStream bis = new BufferedInputStream(new FileInputStream(file))) { int offset; // now write the content of the file to the ZipOutputStream while (-1 != (offset = bis.read(buffer))) { zos.write(buffer, 0, offset); } } } if (log.isTraceEnabled()) log.trace(HelperLog.methodExit()); }
@Override public void dispatchSendMessage(TBase<?, ?> tBase) { // mark accepted time acceptedTimeService.accept(); // TODO consider to change dispatch table automatically SimpleHandler simpleHandler = getSimpleHandler(tBase); if (simpleHandler != null) { if (logger.isTraceEnabled()) { logger.trace("simpleHandler name:{}", simpleHandler.getClass().getName()); } simpleHandler.handleSimple(tBase); return; } Handler handler = getHandler(tBase); if (handler != null) { if (logger.isTraceEnabled()) { logger.trace("handler name:{}", handler.getClass().getName()); } handler.handle(tBase); return; } throw new UnsupportedOperationException( "Handler not found. Unknown type of data received. tBase=" + tBase); }
protected boolean writeBatch() { try { if (handler.getChannel().write(buffer) < 0) { if (log.isTraceEnabled()) { log.trace("Closing channel"); } inError = true; return false; } else if (buffer.hasRemaining()) { if (handler.getChannel().write(buffer) < 0) { if (log.isTraceEnabled()) { log.trace("Closing channel"); } inError = true; return false; } } } catch (IOException e) { if (Utils.isClose(e)) { log.info(String.format("closing acknowledger %s ", fsm.getName())); } else { log.warn( String.format("Unable to write batch commit acknowledgement %s", fsm.getName()), e); } error(); return false; } return !buffer.hasRemaining(); }
@Override public boolean checkPreconditions(ParseConfiguration configuration) { if (configuration.getStack().isEmpty()) { if (LOG.isTraceEnabled()) { LOG.trace("Cannot apply " + this.toString() + ": stack is empty"); } return false; } // top of stack must already have a governor PosTaggedToken topOfStack = configuration.getStack().peek(); PosTaggedToken governor = configuration.getHead(topOfStack); if (governor == null) { if (LOG.isTraceEnabled()) { LOG.trace( "Cannot apply " + this.toString() + ": top of stack " + topOfStack + " doesn't yet have a governor."); } return false; } return true; }
/** Return a bean from the bean cache. */ @SuppressWarnings("unchecked") private T beanCacheGetInternal(Object id, Boolean readOnly, PersistenceContext context) { CachedBeanData data = (CachedBeanData) getBeanCache().get(id); if (data == null) { if (beanLog.isTraceEnabled()) { beanLog.trace(" GET {}({}) - cache miss", cacheName, id); } return null; } if (cacheSharableBeans && !Boolean.FALSE.equals(readOnly)) { Object bean = data.getSharableBean(); if (bean != null) { if (beanLog.isTraceEnabled()) { beanLog.trace(" GET {}({}) - hit shared bean", cacheName, id); } if (desc.isReadAuditing()) { desc.readAuditBean("l2", "", bean); } return (T) bean; } } return (T) loadBean(id, readOnly, data, context); }
/** Returns true if it managed to populate/load the bean from the cache. */ boolean beanCacheLoad( EntityBean bean, EntityBeanIntercept ebi, Object id, PersistenceContext context) { CachedBeanData cacheData = (CachedBeanData) getBeanCache().get(id); if (cacheData == null) { if (beanLog.isTraceEnabled()) { beanLog.trace(" LOAD {}({}) - cache miss", cacheName, id); } return false; } int lazyLoadProperty = ebi.getLazyLoadPropertyIndex(); if (lazyLoadProperty > -1 && !cacheData.isLoaded(ebi.getLazyLoadProperty())) { if (beanLog.isTraceEnabled()) { beanLog.trace( " LOAD {}({}) - cache miss on property({})", cacheName, id, ebi.getLazyLoadProperty()); } return false; } CachedBeanDataToBean.load(desc, bean, cacheData, context); if (beanLog.isDebugEnabled()) { beanLog.debug(" LOAD {}({}) - hit", cacheName, id); } return true; }
@Override public OFMatchV3 readFrom(ChannelBuffer bb) throws OFParseError { int start = bb.readerIndex(); // fixed value property type == 0x1 short type = bb.readShort(); if (type != (short) 0x1) throw new OFParseError("Wrong type: Expected=0x1(0x1), got=" + type); int length = U16.f(bb.readShort()); if (length < MINIMUM_LENGTH) throw new OFParseError( "Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length); if (bb.readableBytes() + (bb.readerIndex() - start) < length) { // Buffer does not have all data yet bb.readerIndex(start); return null; } if (logger.isTraceEnabled()) logger.trace("readFrom - length={}", length); OFOxmList oxmList = OFOxmList.readFrom(bb, length - (bb.readerIndex() - start), OFOxmVer14.READER); // align message to 8 bytes (length does not contain alignment) bb.skipBytes(((length + 7) / 8 * 8) - length); OFMatchV3Ver14 matchV3Ver14 = new OFMatchV3Ver14(oxmList); if (logger.isTraceEnabled()) logger.trace("readFrom - read={}", matchV3Ver14); return matchV3Ver14; }
@Override public OFEchoRequest readFrom(ChannelBuffer bb) throws OFParseError { int start = bb.readerIndex(); // fixed value property version == 1 byte version = bb.readByte(); if (version != (byte) 0x1) throw new OFParseError("Wrong version: Expected=OFVersion.OF_10(1), got=" + version); // fixed value property type == 2 byte type = bb.readByte(); if (type != (byte) 0x2) throw new OFParseError("Wrong type: Expected=OFType.ECHO_REQUEST(2), got=" + type); int length = U16.f(bb.readShort()); if (length < MINIMUM_LENGTH) throw new OFParseError( "Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length); if (bb.readableBytes() + (bb.readerIndex() - start) < length) { // Buffer does not have all data yet bb.readerIndex(start); return null; } if (logger.isTraceEnabled()) logger.trace("readFrom - length={}", length); long xid = U32.f(bb.readInt()); byte[] data = ChannelUtils.readBytes(bb, length - (bb.readerIndex() - start)); OFEchoRequestVer10 echoRequestVer10 = new OFEchoRequestVer10(xid, data); if (logger.isTraceEnabled()) logger.trace("readFrom - read={}", echoRequestVer10); return echoRequestVer10; }
@Override public void run() { final long millisBeforeWarning = conf.getTimeInMillis(Property.TSERV_ASSIGNMENT_DURATION_WARNING); try { long now = System.currentTimeMillis(); KeyExtent extent; RunnableStartedAt runnable; for (Entry<KeyExtent, RunnableStartedAt> entry : activeAssignments.entrySet()) { extent = entry.getKey(); runnable = entry.getValue(); final long duration = now - runnable.getStartTime(); // Print a warning if an assignment has been running for over the configured time length if (duration > millisBeforeWarning) { log.warn( "Assignment for " + extent + " has been running for at least " + duration + "ms", runnable.getTask().getException()); } else if (log.isTraceEnabled()) { log.trace("Assignment for " + extent + " only running for " + duration + "ms"); } } } catch (Exception e) { log.warn("Caught exception checking active assignments", e); } finally { // Don't run more often than every 5s long delay = Math.max((long) (millisBeforeWarning * 0.5), 5000l); if (log.isTraceEnabled()) { log.trace("Rescheduling assignment watcher to run in " + delay + "ms"); } timer.schedule(this, delay); } }
/** * Construct an HttpBasicAuthentication for the given challenge parameters. The challenge * parameters are returned by the web server using a WWW-Authenticate header. This will typically * be represented by single line of the form <code>WWW-Authenticate: Basic realm="myrealm"</code> * * @param challenge WWW-Authenticate header from web server */ protected HttpBasicAuthentication(String challenge, Configuration conf) throws HttpAuthenticationException { setConf(conf); this.challenge = challenge; credentials = new ArrayList(); String username = this.conf.get("http.auth.basic." + challenge + ".user"); String password = this.conf.get("http.auth.basic." + challenge + ".password"); if (LOG.isTraceEnabled()) { LOG.trace("BasicAuthentication challenge is " + challenge); LOG.trace("BasicAuthentication username="******"BasicAuthentication password="******"Username for " + challenge + " is null"); } if (password == null) { throw new HttpAuthenticationException("Password for " + challenge + " is null"); } byte[] credBytes = (username + ":" + password).getBytes(); credentials.add("Authorization: Basic " + new String(Base64.encodeBase64(credBytes))); if (LOG.isTraceEnabled()) { LOG.trace("Basic credentials: " + credentials); } }
@Override public OFActionSetField readFrom(ChannelBuffer bb) throws OFParseError { int start = bb.readerIndex(); // fixed value property type == 25 short type = bb.readShort(); if (type != (short) 0x19) throw new OFParseError("Wrong type: Expected=OFActionType.SET_FIELD(25), got=" + type); int length = U16.f(bb.readShort()); if (length < MINIMUM_LENGTH) throw new OFParseError( "Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length); if (bb.readableBytes() + (bb.readerIndex() - start) < length) { // Buffer does not have all data yet bb.readerIndex(start); return null; } if (logger.isTraceEnabled()) logger.trace("readFrom - length={}", length); OFOxm<?> field = OFOxmVer12.READER.readFrom(bb); // align message to 8 bytes (length contains aligned value) bb.skipBytes(length - (bb.readerIndex() - start)); OFActionSetFieldVer12 actionSetFieldVer12 = new OFActionSetFieldVer12(field); if (logger.isTraceEnabled()) logger.trace("readFrom - read={}", actionSetFieldVer12); return actionSetFieldVer12; }
private Capacidad buscarCapacidad(int capacityCode) { HttpClient httpclient = getHttpClient(); GetMethod get = new GetMethod(restUrl.getCapacidadUrl()); get.addRequestHeader("Accept", "application/xml"); Capacidad ret = null; try { int result = httpclient.executeMethod(get); if (logger.isTraceEnabled()) logger.trace("Response status code: " + result); String xmlString = get.getResponseBodyAsString(); if (logger.isTraceEnabled()) logger.trace("Response body: " + xmlString); ret = importCapacidad(xmlString, capacityCode); } catch (HttpException e) { logger.error(e.getMessage()); } catch (IOException e) { logger.error(e.getMessage()); } catch (ParserConfigurationException e) { logger.error(e.getMessage()); } catch (SAXException e) { logger.error(e.getMessage()); } finally { get.releaseConnection(); } return ret; }
/** * Gets the string body to be used when sending with the textline codec. * * @param body the current body * @param exchange the exchange * @param delimiter the textline delimiter * @param autoAppendDelimiter whether absent delimiter should be auto appended * @return the string body to send * @throws NoTypeConversionAvailableException is thrown if the current body could not be converted * to a String type */ public static String getTextlineBody( Object body, Exchange exchange, TextLineDelimiter delimiter, boolean autoAppendDelimiter) throws NoTypeConversionAvailableException { String s = exchange.getContext().getTypeConverter().mandatoryConvertTo(String.class, exchange, body); // auto append delimiter if missing? if (autoAppendDelimiter) { if (TextLineDelimiter.LINE.equals(delimiter)) { // line delimiter so ensure it ends with newline if (!s.endsWith("\n")) { if (LOG.isTraceEnabled()) { LOG.trace("Auto appending missing newline delimiter to body"); } s = s + "\n"; } } else { // null delimiter so ensure it ends with null if (!s.endsWith("\u0000")) { if (LOG.isTraceEnabled()) { LOG.trace("Auto appending missing null delimiter to body"); } s = s + "\u0000"; } } } return s; }
@Override public OFInstructionIdBsnRequireVlanXlate readFrom(ChannelBuffer bb) throws OFParseError { int start = bb.readerIndex(); // fixed value property type == 65535 short type = bb.readShort(); if (type != (short) 0xffff) throw new OFParseError( "Wrong type: Expected=OFInstructionType.EXPERIMENTER(65535), got=" + type); int length = U16.f(bb.readShort()); if (length != 12) throw new OFParseError("Wrong length: Expected=12(12), got=" + length); if (bb.readableBytes() + (bb.readerIndex() - start) < length) { // Buffer does not have all data yet bb.readerIndex(start); return null; } if (logger.isTraceEnabled()) logger.trace("readFrom - length={}", length); // fixed value property experimenter == 0x5c16c7L int experimenter = bb.readInt(); if (experimenter != 0x5c16c7) throw new OFParseError( "Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got=" + experimenter); // fixed value property subtype == 0x8L int subtype = bb.readInt(); if (subtype != 0x8) throw new OFParseError("Wrong subtype: Expected=0x8L(0x8L), got=" + subtype); if (logger.isTraceEnabled()) logger.trace("readFrom - returning shared instance={}", INSTANCE); return INSTANCE; }
/** * Method description * * @param manager * @return * @throws IOException * @throws RepositoryException */ @Override public List<String> importRepositories(RepositoryManager manager) throws IOException, RepositoryException { List<String> imported = new ArrayList<String>(); if (logger.isTraceEnabled()) { logger.trace("search for repositories to import"); } List<String> repositoryNames = RepositoryUtil.getRepositoryNames(getRepositoryHandler(), getDirectoryNames()); for (String repositoryName : repositoryNames) { if (logger.isTraceEnabled()) { logger.trace("check repository {} for import", repositoryName); } Repository repository = manager.get(getTypeName(), repositoryName); if (repository == null) { importRepository(manager, repositoryName); imported.add(repositoryName); } else if (logger.isDebugEnabled()) { logger.debug("repository {} is allready managed", repositoryName); } } return imported; }
@Override public String processForm(Map<String, String> parameters, Map<String, FileItem> files) throws BadRequestException, NotAuthorizedException, ConflictException { log.trace("process"); try { ByteArrayOutputStream bout = new ByteArrayOutputStream(); Request request = HttpManager.request(); IOUtils.copy(request.getInputStream(), bout); String iCalText = bout.toString("UTF-8"); if (log.isTraceEnabled()) { log.trace("Freebusy query: " + iCalText); } List<SchedulingResponseItem> respItems = queryFreeBusy(iCalText); String xml = schedulingHelper.generateXml(respItems); xmlResponse = xml.getBytes(StringUtils.UTF8); if (log.isTraceEnabled()) { log.trace("FreeBusy response= " + xml); } } catch (IOException ex) { throw new RuntimeException(ex); } return null; }
/** 在访问被拒绝 */ @Override protected boolean onAccessDenied(ServletRequest request, ServletResponse response) throws Exception { if (isLoginRequest(request, response)) { if (isLoginSubmission(request, response)) { if (log.isTraceEnabled()) { log.trace("Login submission detected. Attempting to execute login."); } return executeLogin(request, response); } else { if (log.isTraceEnabled()) { log.trace("Login page view."); } return true; } } else { if (log.isTraceEnabled()) { log.trace( "Attempting to access a path which requires authentication. Forwarding to the " + "Authentication url [" + getLoginUrl() + "]"); } saveRequestAndRedirectToLogin(request, response); return false; } }
private boolean isManaged( RepositoryConnection conn, Resource subject, URI predicate, Value object, String operation) { try { if (conn.hasStatement(subject, predicate, object, true, managedContext)) { // Ignore/Strip any triple that is already present in the mgmt-context (i.e. "unchanged" // props). if (log.isTraceEnabled()) { log.trace( "[{}] filtering out statement that is already present in the managed context: {}", operation, new StatementImpl(subject, predicate, object)); } return true; } else if (this.subject.equals(subject) && managedProperties.contains(predicate)) { // We do NOT allow changing server-managed properties. if (log.isTraceEnabled()) { log.trace( "[{}] filtering out statement with managed propterty {}: {}", operation, predicate, new StatementImpl(subject, predicate, object)); } deniedProperties.add(predicate); return true; } } catch (RepositoryException e) { log.error("Error while filtering server managed properties: {}", e.getMessage()); } return false; }
@Override public OFMeterFeaturesStatsReply readFrom(ByteBuf bb) throws OFParseError { int start = bb.readerIndex(); // fixed value property version == 5 byte version = bb.readByte(); if (version != (byte) 0x5) throw new OFParseError("Wrong version: Expected=OFVersion.OF_14(5), got=" + version); // fixed value property type == 19 byte type = bb.readByte(); if (type != (byte) 0x13) throw new OFParseError("Wrong type: Expected=OFType.STATS_REPLY(19), got=" + type); int length = U16.f(bb.readShort()); if (length != 32) throw new OFParseError("Wrong length: Expected=32(32), got=" + length); if (bb.readableBytes() + (bb.readerIndex() - start) < length) { // Buffer does not have all data yet bb.readerIndex(start); return null; } if (logger.isTraceEnabled()) logger.trace("readFrom - length={}", length); long xid = U32.f(bb.readInt()); // fixed value property statsType == 11 short statsType = bb.readShort(); if (statsType != (short) 0xb) throw new OFParseError( "Wrong statsType: Expected=OFStatsType.METER_FEATURES(11), got=" + statsType); Set<OFStatsReplyFlags> flags = OFStatsReplyFlagsSerializerVer14.readFrom(bb); // pad: 4 bytes bb.skipBytes(4); OFMeterFeatures features = OFMeterFeaturesVer14.READER.readFrom(bb); OFMeterFeaturesStatsReplyVer14 meterFeaturesStatsReplyVer14 = new OFMeterFeaturesStatsReplyVer14(xid, flags, features); if (logger.isTraceEnabled()) logger.trace("readFrom - read={}", meterFeaturesStatsReplyVer14); return meterFeaturesStatsReplyVer14; }
/** {@inheritDoc} */ @Override public void messageReceived(IoSession session, Object message) throws Exception { if (log.isTraceEnabled()) { log.trace("messageReceived session: {} message: {}", session, message); log.trace("Filter chain: {}", session.getFilterChain()); } String sessionId = (String) session.getAttribute(RTMPConnection.RTMP_SESSION_ID); if (log.isTraceEnabled()) { log.trace("Message received on session: {} id: {}", session.getId(), sessionId); } RTMPMinaConnection conn = (RTMPMinaConnection) RTMPConnManager.getInstance().getConnectionBySessionId(sessionId); if (conn != null) { if (message != null) { if (message instanceof Packet) { byte state = conn.getStateCode(); // checking the state before allowing a task to be created will hopefully prevent rejected // task exceptions if (state != RTMP.STATE_DISCONNECTING && state != RTMP.STATE_DISCONNECTED) { conn.handleMessageReceived((Packet) message); } else { log.info( "Ignoring received message on {} due to state: {}", sessionId, RTMP.states[state]); } } } } else { log.warn("Connection was not found for {}, force closing", sessionId); forceClose(session); } }
public void fireUntilHalt(final AgendaFilter agendaFilter) { unstageActivations(); this.halt.set(false); if (log.isTraceEnabled()) { log.trace("Starting fireUntilHalt"); } while (continueFiring(-1)) { boolean fired = fireNextItem(agendaFilter, 0, -1) >= 0 || !((StatefulKnowledgeSessionImpl) this.workingMemory).getActionQueue().isEmpty(); this.workingMemory.executeQueuedActions(); if (!fired) { try { synchronized (this.halt) { if (!this.halt.get()) { this.halt.wait(); } } } catch (InterruptedException e) { this.halt.set(true); } } else { this.workingMemory.executeQueuedActions(); } } if (log.isTraceEnabled()) { log.trace("Ending fireUntilHalt"); } fireUntilHalt = false; }
/** * Send a token to all connected receivers. Tokens are in general immutable, so each receiver is * given a reference to the same token and no clones are made. The transfer is accomplished by * calling getRemoteReceivers() to determine the number of channels with valid receivers and then * calling send() on the appropriate channels. It would probably be faster to call put() directly * on the receivers. If there are no destination receivers, then nothing is sent. If the port is * not connected to anything, or receivers have not been created in the remote port, then just * return. * * <p>Some of this method is read-synchronized on the workspace. Since it is possible for a thread * to block while executing a put, it is important that the thread does not hold read access on * the workspace when it is blocked. Thus this method releases read access on the workspace before * calling put. * * @param token The token to send * @exception IllegalActionException If the token to be sent cannot be converted to the type of * this port * @exception NoRoomException If a send to one of the channels throws it. */ public void broadcast(Token token) throws IllegalActionException, NoRoomException { if (logger.isTraceEnabled()) { logger.trace("broadcast() - entry : " + token); } statistics.acceptSentMessage(null); Receiver[][] farReceivers; // ptolemy debug listener stuff etc if (_debugging) { _debug("broadcast " + token); } try { _workspace.getReadAccess(); _checkType(token); farReceivers = getRemoteReceivers(); if (farReceivers == null) { return; } } finally { _workspace.doneReading(); } // NOTE: This does not call send() here, because send() // repeats the above on each call. for (int i = 0; i < farReceivers.length; i++) { if (farReceivers[i] == null) continue; putAtFarReceivers(token, farReceivers[i]); } if (logger.isTraceEnabled()) { logger.trace("broadcast() - exit"); } }
@Override public OFQueueOpFailedErrorMsg readFrom(ChannelBuffer bb) throws OFParseError { int start = bb.readerIndex(); // fixed value property version == 4 byte version = bb.readByte(); if (version != (byte) 0x4) throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got=" + version); // fixed value property type == 1 byte type = bb.readByte(); if (type != (byte) 0x1) throw new OFParseError("Wrong type: Expected=OFType.ERROR(1), got=" + type); int length = U16.f(bb.readShort()); if (length < MINIMUM_LENGTH) throw new OFParseError( "Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length); if (bb.readableBytes() + (bb.readerIndex() - start) < length) { // Buffer does not have all data yet bb.readerIndex(start); return null; } if (logger.isTraceEnabled()) logger.trace("readFrom - length={}", length); long xid = U32.f(bb.readInt()); // fixed value property errType == 9 short errType = bb.readShort(); if (errType != (short) 0x9) throw new OFParseError( "Wrong errType: Expected=OFErrorType.QUEUE_OP_FAILED(9), got=" + errType); OFQueueOpFailedCode code = OFQueueOpFailedCodeSerializerVer13.readFrom(bb); byte[] data = ChannelUtils.readBytes(bb, length - (bb.readerIndex() - start)); OFQueueOpFailedErrorMsgVer13 queueOpFailedErrorMsgVer13 = new OFQueueOpFailedErrorMsgVer13(xid, code, data); if (logger.isTraceEnabled()) logger.trace("readFrom - read={}", queueOpFailedErrorMsgVer13); return queueOpFailedErrorMsgVer13; }
private int scpExec(Map<String, ?> props, String from, String to) { File tempFile = null; try { List<String> cmd = Lists.newArrayList(); cmd.add(getOptionalVal(props, PROP_SCP_EXECUTABLE, scpExecutable)); cmd.add("-B"); if (privateKeyFile != null) { cmd.add("-i"); cmd.add(privateKeyFile.getAbsolutePath()); } else if (privateKeyData != null) { tempFile = writeTempFile(privateKeyData); cmd.add("-i"); cmd.add(tempFile.getAbsolutePath()); } if (!strictHostKeyChecking) { cmd.add("-o"); cmd.add("StrictHostKeyChecking=no"); } if (port != 22) { cmd.add("-P"); cmd.add("" + port); } cmd.add(from); cmd.add(to); if (LOG.isTraceEnabled()) LOG.trace("Executing with command: {}", cmd); int result = execProcess(props, cmd); if (LOG.isTraceEnabled()) LOG.trace("Executed command: {}; exit code {}", cmd, result); return result; } finally { if (tempFile != null) tempFile.delete(); } }
/** * Creates a OFPacketOut with the OFPacketIn data that is flooded on all ports unless the port is * blocked, in which case the packet will be dropped. * * @param sw The switch that receives the OFPacketIn * @param pi The OFPacketIn that came to the switch * @param cntx The FloodlightContext associated with this OFPacketIn */ @LogMessageDoc( level = "ERROR", message = "Failure writing PacketOut " + "switch={switch} packet-in={packet-in} " + "packet-out={packet-out}", explanation = "An I/O error occured while writing a packet " + "out message to the switch", recommendation = LogMessageDoc.CHECK_SWITCH) protected void doFlood(IOFSwitch sw, OFPacketIn pi, FloodlightContext cntx) { if (topology.isIncomingBroadcastAllowed(sw.getId(), pi.getInPort()) == false) { if (log.isTraceEnabled()) { log.trace( "doFlood, drop broadcast packet, pi={}, " + "from a blocked port, srcSwitch=[{},{}], linkInfo={}", new Object[] {pi, sw.getId(), pi.getInPort()}); } return; } // Set Action to flood OFPacketOut po = (OFPacketOut) floodlightProvider.getOFMessageFactory().getMessage(OFType.PACKET_OUT); List<OFAction> actions = new ArrayList<OFAction>(); if (sw.hasAttribute(IOFSwitch.PROP_SUPPORTS_OFPP_FLOOD)) { actions.add(new OFActionOutput(OFPort.OFPP_FLOOD.getValue(), (short) 0xFFFF)); } else { actions.add(new OFActionOutput(OFPort.OFPP_ALL.getValue(), (short) 0xFFFF)); } po.setActions(actions); po.setActionsLength((short) OFActionOutput.MINIMUM_LENGTH); // set buffer-id, in-port and packet-data based on packet-in short poLength = (short) (po.getActionsLength() + OFPacketOut.MINIMUM_LENGTH); po.setBufferId(pi.getBufferId()); po.setInPort(pi.getInPort()); if (pi.getBufferId() == OFPacketOut.BUFFER_ID_NONE) { byte[] packetData = pi.getPacketData(); poLength += packetData.length; po.setPacketData(packetData); } po.setLength(poLength); try { if (log.isTraceEnabled()) { log.trace( "Writing flood PacketOut switch={} packet-in={} packet-out={}", new Object[] {sw, pi, po}); } messageDamper.write(sw, po, cntx); } catch (IOException e) { log.error( "Failure writing PacketOut switch={} packet-in={} packet-out={}", new Object[] {sw, pi, po}, e); } return; }
@Override @LogMessageDoc( level = "ERROR", message = "Unexpected decision made for this packet-in={}", explanation = "An unsupported PacketIn decision has been " + "passed to the flow programming component", recommendation = LogMessageDoc.REPORT_CONTROLLER_BUG) public Command processPacketInMessage( IOFSwitch sw, OFPacketIn pi, IRoutingDecision decision, FloodlightContext cntx) { Ethernet eth = IFloodlightProviderService.bcStore.get(cntx, IFloodlightProviderService.CONTEXT_PI_PAYLOAD); // If a decision has been made we obey it // otherwise we just forward if (decision != null) { if (log.isTraceEnabled()) { log.trace( "Forwaring decision={} was made for PacketIn={}", decision.getRoutingAction().toString(), pi); } switch (decision.getRoutingAction()) { case NONE: // don't do anything return Command.CONTINUE; case FORWARD_OR_FLOOD: case FORWARD: doForwardFlow(sw, pi, cntx, false); return Command.CONTINUE; case MULTICAST: // treat as broadcast doFlood(sw, pi, cntx); return Command.CONTINUE; case DROP: doDropFlow(sw, pi, decision, cntx); return Command.CONTINUE; default: log.error( "Unexpected decision made for this packet-in={}", pi, decision.getRoutingAction()); return Command.CONTINUE; } } else { if (log.isTraceEnabled()) { log.trace("No decision was made for PacketIn={}, forwarding", pi); } if (eth.isBroadcast() || eth.isMulticast()) { // For now we treat multicast as broadcast doFlood(sw, pi, cntx); } else { doForwardFlow(sw, pi, cntx, false); } } return Command.CONTINUE; }