Examples of InvalidRequestParamValueException


Examples of com.linkedin.databus2.core.container.request.InvalidRequestParamValueException

  throws IOException, RequestProcessingException, DatabusException
  {
    String category = request.getParams().getProperty(DatabusRequest.PATH_PARAM_NAME);
    if (category == null)
    {
      throw new InvalidRequestParamValueException(COMMAND_NAME, "category", "null");
    }
    LOG.info("Processing command " + category);

    if (category.equals(CLIENT_INFO_KEY))
    {
      Map<String, String> outMap = null;
      outMap = _client.printClientInfo();
      writeJsonObjectToResponse(outMap, request);
    }
    else if (category.equals(RESET_RELAY_CONNECTIONS))
    {
      _client.resetRelayConnections();
    }
    else
    {
      throw new InvalidRequestParamValueException(COMMAND_NAME, "category", category);
    }

    return request;
  }
View Full Code Here

Examples of com.linkedin.databus2.core.container.request.InvalidRequestParamValueException

          String response="{\"pid\":\""+ pid + "\"}";
          request.getResponseContent().write(ByteBuffer.wrap(response.getBytes(Charset.defaultCharset())));
        }
      else
      {
        throw new InvalidRequestParamValueException(COMMAND_NAME, "request path", action);
      }
      return request;
  }
View Full Code Here

Examples of com.linkedin.databus2.core.container.request.InvalidRequestParamValueException

      int clientEventVersion = (clientMaxEventVersionStr != null) ?
          Integer.parseInt(clientMaxEventVersionStr) : DbusEventFactory.DBUS_EVENT_V1;

      if (clientEventVersion < 0 || clientEventVersion == 1 || clientEventVersion > DbusEventFactory.DBUS_EVENT_V2)
      {
        throw new InvalidRequestParamValueException(COMMAND_NAME,
                                                    DatabusHttpHeaders.MAX_EVENT_VERSION,
                                                    clientMaxEventVersionStr);
      }

      if (null == sourcesListStr && null == subsStr)
      {
        throw new InvalidRequestParamValueException(COMMAND_NAME, SOURCES_PARAM + "|" + SUBS_PARAM, "null");
      }

      //TODO for now we separte the code paths to limit the impact on existing Databus 2 deployments (DDSDBUS-79)
      //We have to get rid of this eventually and have a single data path.
      boolean v2Mode = null == subsStr;

      DbusKeyCompositeFilter keyCompositeFilter = null;
      if ( null != partitionInfoStr)
      {
        try
        {
          Map<Long, DbusKeyFilter> fMap= KeyFilterConfigJSONFactory.parseSrcIdFilterConfigMap(partitionInfoStr);
          keyCompositeFilter = new DbusKeyCompositeFilter();
          keyCompositeFilter.setFilterMap(fMap);
          if ( isDebug)
            LOG.debug("keyCompositeFilter is :" + keyCompositeFilter);
        } catch ( Exception ex) {
          String msg = "Got exception while parsing partition Configs. PartitionInfo is:" + partitionInfoStr;
          LOG.error(msg, ex);
          throw new InvalidRequestParamValueException(COMMAND_NAME, PARTITION_INFO_STRING, partitionInfoStr);
        }
      }


      boolean streamFromLatestSCN = false;

      if ( null != streamFromLatestSCNStr)
      {
        streamFromLatestSCN = Boolean.valueOf(streamFromLatestSCNStr);
      }

      long start = System.currentTimeMillis();

      List<DatabusSubscription> subs = null;

      //parse source ids
      SourceIdNameRegistry srcRegistry = _relay.getSourcesIdNameRegistry();
      HashSet<Integer> sourceIds = new HashSet<Integer>();
      if (null != sourcesListStr)
      {
        String[] sourcesList = sourcesListStr.split(",");
        for (String sourceId: sourcesList)
        {
          try
          {
            Integer srcId = Integer.valueOf(sourceId);
            sourceIds.add(srcId);
          }
          catch (NumberFormatException nfe)
          {
            HttpStatisticsCollector globalHttpStatsCollector = _relay.getHttpStatisticsCollector();
            if (null != globalHttpStatsCollector) {
              globalHttpStatsCollector.registerInvalidStreamRequest();
            }
            throw new InvalidRequestParamValueException(COMMAND_NAME, SOURCES_PARAM, sourceId);
          }
        }
      }

      //process explicit subscriptions and generate respective logical partition filters
      NavigableSet<PhysicalPartitionKey> ppartKeys = null;
      if (null != subsStr)
      {
        List<DatabusSubscription.Builder> subsBuilder = null;
        subsBuilder = objMapper.readValue(subsStr,
                                          new TypeReference<List<DatabusSubscription.Builder>>(){});
        subs = new ArrayList<DatabusSubscription>(subsBuilder.size());
        for (DatabusSubscription.Builder subBuilder: subsBuilder)
        {
          subs.add(subBuilder.build());
        }

        ppartKeys = new TreeSet<PhysicalPartitionKey>();
        for (DatabusSubscription sub: subs)
        {
          PhysicalPartition ppart = sub.getPhysicalPartition();
          if (ppart.isAnyPartitionWildcard())
          {
            ppartKeys = _eventBuffer.getAllPhysicalPartitionKeys(); break;
          }
          else
          {
            ppartKeys.add(new PhysicalPartitionKey(ppart));
          }
        }
      }
      // TODO
      // The following if statement is a very conservative one just to make sure that there are
      // not some clients out there that send subs, but do not send checkpoint mult. It seems that
      // this was the case during development but never in production, so we should remove this
      // pretty soon (1/28/2013).
      // Need to make sure that we don't have tests that send requests in this form.
      if(subs != null && checkpointStringMult == null && checkpointString != null) {
        throw new RequestProcessingException("Both Subscriptions and CheckpointMult should be present");
      }

      //convert source ids into subscriptions
      if (null == subs) subs = new ArrayList<DatabusSubscription>();
      for (Integer srcId: sourceIds)
      {
        LogicalSource lsource = srcRegistry.getSource(srcId);
        if(lsource == null)
          throw new InvalidRequestParamValueException(COMMAND_NAME, SOURCES_PARAM, srcId.toString());
        if(isDebug)
          LOG.debug("registry returns " + lsource  + " for srcid="+ srcId);
        DatabusSubscription newSub = DatabusSubscription.createSimpleSourceSubscription(lsource);
        subs.add(newSub);
      }

      DbusFilter ppartFilters = null;
      if (subs.size() > 0)
      {
        try
        {
          ppartFilters = _eventBuffer.constructFilters(subs);
        }
        catch (DatabusException de)
        {
          throw new RequestProcessingException("unable to generate physical partitions filters:" +
                                               de.getMessage(),
                                               de);
        }
      }

      ConjunctionDbusFilter filters = new ConjunctionDbusFilter();

      // Source filter comes first
      if (v2Mode) filters.addFilter(new SourceDbusFilter(sourceIds));
      else if (null != ppartFilters) filters.addFilter(ppartFilters);

      /*
      // Key range filter comes next
      if ((keyMin >0) && (keyMax > 0))
      {
        filters.addFilter(new KeyRangeFilter(keyMin, keyMax));
      }
      */
      if ( null != keyCompositeFilter)
      {
        filters.addFilter(keyCompositeFilter);
      }

      // need to update registerStreamRequest to support Mult checkpoint TODO (DDSDBUS-80)
      // temp solution
      // 3 options:
      // 1. checkpointStringMult not null - generate checkpoint from it
      // 2. checkpointStringMult null, checkpointString not null - create empty CheckpointMult
      // and add create Checkpoint(checkpointString) and add it to cpMult;
      // 3 both are null - create empty CheckpointMult and add empty Checkpoint to it for each ppartition
      PhysicalPartition pPartition;

      Checkpoint cp = null;
      CheckpointMult cpMult = null;

      if(checkpointStringMult != null) {
        try {
          cpMult = new CheckpointMult(checkpointStringMult);
        } catch (InvalidParameterSpecException e) {
          LOG.error("Invalid CheckpointMult:" + checkpointStringMult, e);
          throw new InvalidRequestParamValueException("stream", "CheckpointMult", checkpointStringMult);
        }
      } else {
        // there is no checkpoint - create an empty one
        cpMult = new CheckpointMult();
        Iterator<Integer> it = sourceIds.iterator();
View Full Code Here

Examples of com.linkedin.databus2.core.container.request.InvalidRequestParamValueException

  public DatabusRequest process(DatabusRequest request) throws IOException, RequestProcessingException {

    String command = request.getParams().getProperty(DatabusRequest.PATH_PARAM_NAME);
    if (null == command)
    {
      throw new InvalidRequestParamValueException(COMMAND_NAME, "command", "null");
    }

    String reply = "Command " + command  + " completed ";
    LOG.info("got relayCommand = " + command);
    if(command.equals(SAVE_META_STATE_PARAM)) {
      _relay.saveBufferMetaInfo(true);
    } else if (command.equals(SHUTDOWN_RELAY_PARAM)) {
      String msg = "received shutdown curl request from: " + request.getRemoteAddress() + ". Shutting down\n";
      LOG.warn(msg);
      request.getResponseContent().write(ByteBuffer.wrap(msg.getBytes("UTF-8")));
      request.getResponseContent().close();
      _relay.shutdown();
    } else if (command.equals(VALIDATE_RELAY_BUFFER_PARAM)) {
      _relay.validateRelayBuffers();
    } else if (command.equals(DISCONNECT_CLIENTS)) {
      Channel rspChannel = request.getResponseContent().getRawChannel();
      _relay.disconnectDBusClients(rspChannel);
    } else if (command.equals(RUN_GC_PARAM)) {
      Runtime rt = Runtime.getRuntime();
      long mem = rt.freeMemory();
      LOG.info("mem before gc = " + rt.freeMemory() + " out of " + rt.totalMemory());
      long time = System.currentTimeMillis();
      System.gc();
      time = System.currentTimeMillis() - time;
      mem = rt.freeMemory() - mem;
      reply = new String("GC run. Took " + time + " millsecs. Freed " + mem + " bytes out of " + rt.totalMemory());
    } else if(command.startsWith(RESET_RELAY_BUFFER_PARAM)) {
      // We expect the request to be of the format:
      //   resetRelayBuffer/<dbName>/<partitionId>?prevScn=<long>&binlogOffset=<long>
      String [] resetCommands = command.split("/");
      if(resetCommands.length != 3) {
        throw new InvalidRequestParamValueException(COMMAND_NAME, "command", command);
      }
      String dbName = resetCommands[1];
      String dbPart = resetCommands[2];
      long prevScn = request.getRequiredLongParam(PREV_SCN_PARAM);
      long binlogOffset = request.getOptionalLongParam(BINLOG_OFFSET_PARAM, 0L);
      LOG.info("reset command = " + dbName + " part =" + dbPart);
      try
      {
        _relay.resetBuffer(new PhysicalPartition(Integer.parseInt(dbPart), dbName), prevScn, binlogOffset);
      }
      catch(BufferNotFoundException e)
      {
        reply = new String("command " + command + ":" + e.getMessage());
      }
    } else if(command.startsWith(GET_BINLOG_OFFSET_PARAM)) {
      String[] getOfsArgs = command.split("/");
      if (getOfsArgs.length != 2) {
        throw new InvalidRequestParamValueException(GET_BINLOG_OFFSET_PARAM, "Server ID", "");
      }
      int serverId;
      try
      {
        serverId = Integer.parseInt(getOfsArgs[1]);
        int [] offset  = _relay.getBinlogOffset(serverId);
        if (offset.length != 2) {
          reply = "Error getting binlog offset";
        } else {
          reply = new String("RelayLastEvent(" + offset[0] + "," + offset[1] + ")");
        }
      }
      catch(NumberFormatException e)
      {
        throw new InvalidRequestParamValueException(GET_BINLOG_OFFSET_PARAM, "Server ID", getOfsArgs[1]);
      }
      catch(DatabusException e)
      {
        reply = new String("command " + command + "failed with:" + e.getMessage());
      }
View Full Code Here

Examples of com.linkedin.databus2.core.container.request.InvalidRequestParamValueException

  {
      String category = request.getParams().getProperty(DatabusRequest.PATH_PARAM_NAME);

      if (null == category)
      {
        throw new InvalidRequestParamValueException(COMMAND_NAME, "category", "null");
      }
     
      if ( category.startsWith(INBOUND_VIEW))
      {
          String sourceIdStr = category.substring(INBOUND_VIEW.length());
          sourceIdStr = sourceIdStr.replace('/', ':');
          PhysicalPartition pPartition = PhysicalPartition.parsePhysicalPartitionString(sourceIdStr, ":");
          processInboundRequest(request,pPartition);
      } else {
        throw new InvalidRequestParamValueException(COMMAND_NAME, "category", category);
      }
     
    return request;
  }
View Full Code Here

Examples of com.linkedin.databus2.core.container.request.InvalidRequestParamValueException

          if (null != source) sourcesIdList.add(source.asIdNamePair());
          else LOG.error("unable to find source id: " + id);
        }
        catch (NumberFormatException nfe)
        {
          throw new InvalidRequestParamValueException(COMMAND_NAME, SOURCES_NAME_PARAM, sourceIdStr);
        }

      }

      //We have to use the global stats collector because the generation can go beyond the lifespan
      //of the connection
      boolean tryStart = _producer.startGeneration(fromScn, eventsPerSec, durationMs,
                                                   numEventToGenerate, percentOfBufferToGenerate,
                                                   keyMin, keyMax,
                                                   sourcesIdList, _relayStatsCollector);
      StringBuilder resBuilder = new StringBuilder(1024);
      Formatter fmt = new Formatter(resBuilder);
      fmt.format("{\"genDataEventsStarted\":\"%b\"}", tryStart);

      request.getResponseContent().write(ByteBuffer.wrap(resBuilder.toString().getBytes(Charset.defaultCharset())));
    }
    else
    {
      throw new InvalidRequestParamValueException(COMMAND_NAME, "request path", action);
    }

    return request;
  }
View Full Code Here

Examples of com.linkedin.databus2.core.container.request.InvalidRequestParamValueException

          registerRequestProtocolVersion = Integer.parseInt(registerRequestProtocolVersionStr);
        }
        catch (NumberFormatException e)
        {
          LOG.error("Could not parse /register request protocol version: " + registerRequestProtocolVersionStr);
          throw new InvalidRequestParamValueException(COMMAND_NAME, DatabusHttpHeaders.PROTOCOL_VERSION_PARAM,
                                                      registerRequestProtocolVersionStr);
        }
        if (registerRequestProtocolVersion < 2 || registerRequestProtocolVersion > 4)
        {
          LOG.error("Out-of-range /register request protocol version: " + registerRequestProtocolVersionStr);
          throw new InvalidRequestParamValueException(COMMAND_NAME, DatabusHttpHeaders.PROTOCOL_VERSION_PARAM,
                                                      registerRequestProtocolVersionStr);
        }
      }

      Collection<LogicalSource> logicalSources = null;
      HttpStatisticsCollector relayStatsCollector = _relay.getHttpStatisticsCollector();

      String sources = request.getParams().getProperty(SOURCES_PARAM);
      if (null == sources)
      {
        // need to return all schemas, so first get all sources
        logicalSources = _relay.getSourcesIdNameRegistry().getAllSources();
      }
      else
      {
        String[] sourceIds = sources.split(",");
        logicalSources = new ArrayList<LogicalSource>(sourceIds.length);

        for (String sourceId: sourceIds)
        {
          int srcId;
          String trimmedSourceId = sourceId.trim();
          try
          {
            srcId = Integer.valueOf(trimmedSourceId);
            LogicalSource lsource = _relay.getSourcesIdNameRegistry().getSource(srcId);
            if (null != lsource) logicalSources.add(lsource);
            else
            {
              LOG.error("No source name for source id: " + srcId);
              throw new InvalidRequestParamValueException(COMMAND_NAME, SOURCES_PARAM, sourceId);
            }
          }
          catch (NumberFormatException nfe)
          {
            if (relayStatsCollector != null)
            {
              relayStatsCollector.registerInvalidRegisterCall();
            }
            throw new InvalidRequestParamValueException(COMMAND_NAME, SOURCES_PARAM, sourceId);
          }
        }
      }

      SchemaRegistryService schemaRegistry = _relay.getSchemaRegistryService();
View Full Code Here

Examples of com.linkedin.databus2.core.container.request.InvalidRequestParamValueException

    String psourceName = null;
    if(category.startsWith(INBOUND_GG_PSOURCE_PREFIX)) {
      psourceName = category.substring(INBOUND_GG_PSOURCE_PREFIX.length());
      if(psourceName == null || psourceName.length() <= 0) {
        throw new InvalidRequestParamValueException(request.getName(), INBOUND_GG_PSOURCE_PREFIX, null);
      }
      LOG.info("get parser stats for source " + psourceName);
    }

    List<String> phSourceNames = new ArrayList<String>();
    EventProducer [] prods = ((DatabusRelayMain)_relay).getProducers();
    GGParserStatistics stat = null;
    for(EventProducer prod : prods) {
      if (prod != null && (prod instanceof GoldenGateEventProducer)) {
        GoldenGateEventProducer ggProducer = (GoldenGateEventProducer)prod;
        String pSrcName = ggProducer.getParserStats().getPhysicalSourceName();
        phSourceNames.add(pSrcName);
        if(psourceName != null && psourceName.equals(pSrcName)) // remember the stats object
          stat = ggProducer.getParserStats();
      }
    }

    if(psourceName != null) {
      if(stat == null)
        throw new InvalidRequestParamValueException(request.getName(), INBOUND_GG_PSOURCE_PREFIX, psourceName);
      writeJsonObjectToResponse(stat, request);
    } else {
      writeJsonObjectToResponse(phSourceNames, request);
    }
View Full Code Here

Examples of com.linkedin.databus2.core.container.request.InvalidRequestParamValueException

    {
      sourceId = Integer.valueOf(sourceIdStr);
    }
    catch (NumberFormatException nfe)
    {
      throw new InvalidRequestParamValueException(request.getName(), OUTBOUND_HTTP_SOURCE_PREFIX,
                                                  sourceIdStr);
    }

    DbusHttpTotalStats sourceStats = _relay.getHttpStatisticsCollector().getSourceStats(sourceId);
    if (null == sourceStats)
    {
      throw new InvalidRequestParamValueException(request.getName(), OUTBOUND_HTTP_SOURCE_PREFIX,
                                                  sourceIdStr);
    }

    writeJsonObjectToResponse(sourceStats, request);
View Full Code Here

Examples of com.linkedin.databus2.core.container.request.InvalidRequestParamValueException

    String client = category.substring(OUTBOUND_HTTP_CLIENT_PREFIX.length());

    DbusHttpTotalStats clientStats = _relay.getHttpStatisticsCollector().getPeerStats(client);
    if (null == clientStats)
    {
      throw new InvalidRequestParamValueException(request.getName(), OUTBOUND_HTTP_CLIENT_PREFIX,
                                                  client);
    }

    writeJsonObjectToResponse(clientStats, request);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.