public final HTTPRouterStageConfig<HTTPContentTypeDefaults, HTTPRevisionDefaults, HTTPVerbDefaults, HTTPHeaderDefaults> routerConfig() { if (null==routerConfig) { assert(null!=server) : "No server defined!"; if (null==server) { throw new UnsupportedOperationException("Server must be defined BEFORE any routes."); } routerConfig = new HTTPRouterStageConfig<HTTPContentTypeDefaults, HTTPRevisionDefaults, HTTPVerbDefaults, HTTPHeaderDefaults>( httpSpec, server.connectionStruct()); } return routerConfig; }
public int getRouteIdForPathId(int pathId) { return (pathId != UNMAPPED_ROUTE) ? extractionParser(pathId).routeId : -1; }
@Override public long lookupFieldByName(int id, String name) { if ((id & StructRegistry.IS_STRUCT_BIT) == 0) { //this is a route so we must covert to struct id = routerConfig.getStructIdForRouteId(id); } return gm.recordTypeData.fieldLookup(name, id); }
public boolean appendPipeIdMappingForExcludedGroupIds( Pipe<HTTPRequestSchema> pipe, int track, ArrayList<Pipe<HTTPRequestSchema>>[][] collectedHTTPRequstPipes, int ... groupsIds) { boolean added = false; for(int pathId = 0; pathId<pathToRoute.length; pathId++) { if (null!=pathToRoute[pathId]) { if (!contains(groupsIds, pathToRoute[pathId].routeId)) { added = true; ArrayList<Pipe<HTTPRequestSchema>> targetList = collectedHTTPRequstPipes[track][pathToRoute[pathId].routeId]; if (!targetList.contains(pipe)) { targetList.add(pipe); } } } else { assert(assertRestNull(pathId)); break;//nothing will be found past the null } } return added; }
structId = config.extractionParser(pathId).structId; assert(config.getStructIdForRouteId(routeId) == structId) : "internal error"; DataOutputBlobWriter.tryClearIntBackData(writer,config.totalSizeOfIndexes(structId)); if (!captureAllArgsFromURL(config, trieReader, pathId, writer)) { return sendError(trieReader, channel, idx, tempLen, tempPos); headerMap = config.headerParserRouteId( routeId ); DataOutputBlobWriter.tryClearIntBackData(writer,config.totalSizeOfIndexes(structId)); TrieParserReader.writeCapturedValuesToDataOutput(trieReader, writer, config.unmappedIndexPos,null); if (serverCon!=null) { assert (routeId == config.getRouteIdForPathId(pathId));
@Override public CompositeRoute path(CharSequence path) { int pathsId = pathCounter.getAndIncrement(); //logger.trace("pathId: {} assinged for path: {}",pathsId, path); FieldExtractionDefinitions fieldExDef = parser.addPath(path, routeId, pathsId, structId);//hold for defaults.. activePathFieldIndexPosLookup = new int[fieldExDef.getIndexCount()]; activePathFieldValidator = new Object[fieldExDef.getIndexCount()]; //this visitor will populate the above 2 member arrays we just created fieldExDef.getFieldParamParser().visitPatterns(modifyStructVisitor); fieldExDef.setPathFieldLookup(activePathFieldIndexPosLookup, activePathFieldValidator); config.storeRequestExtractionParsers(pathsId, fieldExDef); //this looked up by pathId config.storeRequestedJSONMapping(routeId, extractor); assert(structId == config.getStructIdForRouteId(routeId)); defs.add(fieldExDef); //System.out.println("added path:"+path); //System.out.println("known routes defined:\n"+parser.debugRouterMap()); return this; }
int routeId = getRouteIdForPathId((int)pathId); if (routeId>=0) { FieldExtractionDefinitions ep = extractionParser((int)pathId);
private void addRoutesToPipeMapping(int ... routeIds) { final PipeConfig<HTTPRequestSchema> pipeConfig = builder.pcm.getConfig(HTTPRequestSchema.class); final int track = parallelInstance==-1 ? 0 : parallelInstance; int i = routeIds.length; while (--i>=0) { if (null==builder.routerConfig().JSONExtractor(routeIds[i])) { //this route does not use JSON so we can join them together if (-1 == pipeIndexForNonJSONRequests) {//the one ring to rule them all was not yet forged. pipeIndexForNonJSONRequests = inputPipes.length; inputPipes = PronghornStage.join(inputPipes, builder.newHTTPRequestPipe(pipeConfig)); } restRoutesDefined |= builder.appendPipeMappingIncludingGroupIds( (Pipe<HTTPRequestSchema>) inputPipes[pipeIndexForNonJSONRequests], track, routeIds); } else { //every JSON request needs its own ring. Pipe<HTTPRequestSchema> jsonPipe = builder.newHTTPRequestPipe(pipeConfig); inputPipes = PronghornStage.join(inputPipes, jsonPipe); restRoutesDefined |= builder.appendPipeMappingIncludingGroupIds(jsonPipe, track, routeIds); } } }
/** * A method to append pipe mapping but not including group ids when invoked by builder * @param pipe Pipe arg used for routerConfig().appendPipeIdMappingForExcludedGroupIds * @param parallelId int arg used for routerConfig().appendPipeIdMappingForExcludedGroupIds * @param routeIds int arg used for routerConfig().appendPipeIdMappingForExcludedGroupIds * @return routerConfig().appendPipeIdMappingForExcludedGroupIds(pipe, parallelId, collectedHTTPRequestPipes, groupIds) */ public final boolean appendPipeMappingExcludingGroupIds(Pipe<HTTPRequestSchema> pipe, int parallelId, int ... routeIds) { lazyCreatePipeLookupMatrix(); return routerConfig().appendPipeIdMappingForExcludedGroupIds(pipe, parallelId, collectedHTTPRequestPipes, routeIds); }
/** * A method to append pipe mapping and group ids when invoked by builder * @param pipe Pipe arg used for routerConfig().appendPipeIdMappingForIncludedGroupIds * @param track int arg used for routerConfig().appendPipeIdMappingForIncludedGroupIds * @param routeIds int arg used for routerConfig().appendPipeIdMappingForIncludedGroupIds * @return routerConfig().appendPipeIdMappingForIncludedGroupIds(pipe, parallelId, collectedHTTPRequestPipes, groupIds) */ public final boolean appendPipeMappingIncludingGroupIds(Pipe<HTTPRequestSchema> pipe, int track, int ... routeIds) { lazyCreatePipeLookupMatrix(); return routerConfig().appendPipeIdMappingForIncludedGroupIds(pipe, track, collectedHTTPRequestPipes, routeIds); }
private static boolean captureAllArgsFromURL(HTTPRouterStageConfig<?,?,?,?> config, TrieParserReader trieReader, final int pathId, DataOutputBlobWriter<HTTPRequestSchema> writer) { final FieldExtractionDefinitions fed = HTTPRouterStageConfig.fieldExDef(config,pathId); if (0 == fed.paramIndexArray().length) { //load any defaults fed.processDefaults(writer); return true; } else { if (TrieParserReader.writeCapturedValuesToDataOutput(trieReader, writer, fed.paramIndexArray(), fed.paramIndexArrayValidator() )) { //load any defaults if what was passed in has been validated fed.processDefaults(writer); return true; } } return false; }
return noHeaderToken(serverConnection, errorReporter2, ccId, requestContext, remainingLen); } else if (HTTPSpecification.UNKNOWN_HEADER_ID != headerToken) { HTTPHeader header = config.getAssociatedObject(headerToken); int writePosition = writer.position();
while (--routeIdx>=0) { JSONExtractorCompleted extractor = routerConfig.JSONExtractor(routeIdx); if (null != extractor) {
public boolean appendPipeIdMappingForIncludedGroupIds( Pipe<HTTPRequestSchema> pipe, int track, ArrayList<Pipe<HTTPRequestSchema>>[][] collectedHTTPRequstPipes, int ... routeId) { boolean added = false; for(int pathId = 0; pathId<pathToRoute.length; pathId++) { if (null!=pathToRoute[pathId]) { //if this pathId belongs to one of this pipes routes then add it. if (contains(routeId, pathToRoute[pathId].routeId)) { added = true; ArrayList<Pipe<HTTPRequestSchema>> targetList = collectedHTTPRequstPipes[track][pathToRoute[pathId].routeId]; //if this pipe is already in the list for this route do not add it again. if (!targetList.contains(pipe)) { targetList.add(pipe); } } } else { assert(assertRestNull(pathId)); break;//nothing will be found past the null } } return added; }
@Override public long lookupFieldByIdentity(int id, Object obj) { if ((id & StructRegistry.IS_STRUCT_BIT) == 0) { //this is a route so we must covert to struct id = routerConfig.getStructIdForRouteId(id); } return gm.recordTypeData.fieldLookupByIdentity(obj, id); }
final HTTPRouterStageConfig routerConfig = new HTTPRouterStageConfig(httpSpec, coordinator.connectionStruct());
public final int routeExtractionParserIndexCount(int route) { return routerConfig().extractionParser(route).getIndexCount(); }