Package com.linkedin.databus2.core

Examples of com.linkedin.databus2.core.DatabusException


      {
        config = _configBuilder.build();
      }
      catch (InvalidConfigException ice)
      {
        throw new DatabusException("unable to create sequence number handler: " + ice.getMessage(),
                                   ice);
      }
      try
      {
        result = FileMaxSCNHandler.create(config);
      }
      catch (IOException ioe)
      {
        throw new DatabusException("unable to create sequence number handler: " + ioe.getMessage(),
                                   ioe);
      }
      _configBuilder.setKey(saveKey);
    }
View Full Code Here


      if (! newIds.containsAll(curIds))
      {
          String msg = "Expected schemas for sources " + curIds + "; got: " + newIds;
          _log.error(msg);
          _currentState.switchToClosed();
          enqueueMessage(LifecycleMessage.createSuspendOnErroMessage(new DatabusException(msg)));
          return;
      }
    }
    _currentState.setSourcesSchemas(sourcesMessage.getSourcesSchemas());
    _sourcesConn.getBootstrapDispatcher().enqueueMessage(sourcesMessage);
View Full Code Here

    if (0 == serversNum)
    {
      //enqueueMessage(LifecycleMessage.createSuspendOnErroMessage(
      //    new DatabusException("No bootstrap services specified")));
      _sourcesConn.getConnectionStatus().suspendOnError(new DatabusException("No bootstrap services specified"));
      return;
    }

    if (null == _resumeCkpt)
    {
      _sourcesConn.getConnectionStatus().suspendOnError(new DatabusException("Bootstrapping checkpoint is not set!"));
      return;
    }

    boolean restartBootstrap = false;
    String bsServerInfo = _resumeCkpt.getBootstrapServerInfo();
    ServerInfo lastReadBS = null;
    if ( null != bsServerInfo)
    {
      try
      {
        lastReadBS = ServerInfo.buildServerInfoFromHostPort(bsServerInfo, DbusConstants.HOSTPORT_DELIMITER);
      } catch(Exception ex) {
        _log.error("Unable to fetch bootstrap serverInfo from checkpoint, ServerInfo :" + bsServerInfo, ex);
      }
    }

    if ( null == lastReadBS)
      restartBootstrap = true;

    int retriesLeft = 0;
    DatabusBootstrapConnection bootstrapConn = null;
    ServerInfo serverInfo = lastReadBS;
    if ( !restartBootstrap )
    {
        //attempt to reconnect to the last used bootstrap server
        while (null == bootstrapConn && (retriesLeft = _retriesBeforeCkptCleanup.getRemainingRetriesNum()) >= 0
               && !checkForShutdownRequest())
        {

            _log.info("Retry picking last used bootstrap server :" + serverInfo +
                      "; retries left:" + retriesLeft);

            if (lastReadBS.equals(_curServer) ) // if it is new server do not sleep?
              _retriesBeforeCkptCleanup.backoffAndSleep();

            try
            {
              bootstrapConn = _sourcesConn.getBootstrapConnFactory().createConnection(serverInfo, this,
                                                                                      _remoteExceptionHandler);
              _log.info("picked last used bootstrap server:" + serverInfo);
            }
            catch (Exception e)
            {
              _log.error("Unable to get connection to bootstrap server:" + serverInfo, e);
            }
        }

        if ((null == bootstrapConn) && (_retriesBeforeCkptCleanup.getRemainingRetriesNum() < 0))
        {
          _log.info("Exhausted retrying the same bootstrap server :" + lastReadBS);
        }
    }

    if(checkForShutdownRequest()) {
      _log.info("Shutting down bootstrap");
      return;
    }

    Random rng = new Random();

    if ( null == bootstrapConn)
    {
      _log.info("Restarting bootstrap as client might be getting bootstrap data from different server instance !!");
      _log.info("Old Checkpoint :" + _resumeCkpt);
      curState.getBstCheckpointHandler().resetForServerChange(_resumeCkpt);
      _log.info("New Checkpoint :" + _resumeCkpt);
      _retriesBeforeCkptCleanup.reset();
    else {
        _curServer = serverInfo;
    }

    while ((null == bootstrapConn) && (retriesLeft = _status.getRetriesLeft()) >= 0 &&
           !checkForShutdownRequest())
    {
      _log.info("picking a bootstrap server; retries left:" + retriesLeft);

      backoffOnPullError();

      _curServerIdx =  (_curServerIdx < 0) ? rng.nextInt(serversNum)
                                           : (_curServerIdx + 1) % serversNum;

      Iterator<ServerInfo> setIter = _servers.iterator();
      for (int i = 0; i <= _curServerIdx; ++i) serverInfo = setIter.next();

      _curServer = serverInfo;

      try
      {
        bootstrapConn = _sourcesConn.getBootstrapConnFactory().createConnection(serverInfo, this, _remoteExceptionHandler);
        _log.info("picked a bootstrap server:" + serverInfo.toSimpleString());
      }
      catch (Exception e)
      {
        _log.error("Unable to get connection to bootstrap server:" + serverInfo, e);
      }
    }

    /*
     * Close the old bootstrap Connection
     */
     DatabusBootstrapConnection oldBootstrapConn = curState.getBootstrapConnection();

     if ( null != oldBootstrapConn)
         resetConnectionAndSetFlag();
     _lastOpenConnection = bootstrapConn;

    if (checkForShutdownRequest()) return;

    if (null == bootstrapConn)
    {
      _log.error("bootstrap server retries exhausted");
      enqueueMessage(LifecycleMessage.createSuspendOnErroMessage(new DatabusException("bootstrap server retries exhausted")));
      return;
    }

    sendHeartbeat(_sourcesConn.getUnifiedClientStats());

View Full Code Here

          _bootstrapSeedWriter.endEvents(BootstrapEventBuffer.END_OF_SOURCE, endScn, null);
          summaries.add(summary);
        }
      } catch (Exception ex) {
        error = true;
        throw new DatabusException(ex);
      } finally {
        // Notify writer that I am done
        if ( error )
        {
          _bootstrapSeedWriter.endEvents(BootstrapEventBuffer.ERROR_CODE, endScn,null);
View Full Code Here

          } else if ((numRowsThisRound == _numRowsPerQuery) && (numUniqueKeysThisRound <= 1)) {
            String msg = "Seeding stuck at infinte loop for source : " + sourceInfo.getEventView() + ", numRowsThisRound :"
                         + numRowsThisRound + ", _numRowsPerQuery :" + _numRowsPerQuery
                         + ", numUniqueKeys :" + numUniqueKeysThisRound + ", lastChunkKey :" + lastRoundKeyTxn;
            LOG.error(msg);
            throw new DatabusException(msg);
          } else if ( null != endKeyTxn) {
            if ( endKeyTxn.compareKey(lastKeyTxn) < 0 ) {
              LOG.info("Seeding stopped for source :" + sourceInfo.getEventView()
                    + ", as it has completed seeding upto the endSrckey :" + endKeyTxn + ", numRowsThisRound :"
                           + numRowsThisRound + ", _numRowsPerQuery :" + _numRowsPerQuery
                           + ", numUniqueKeys :" + numUniqueKeysThisRound + " , Current SrcKey :" + lastKeyTxn);
              done = true;
            }
          }

          if (currRowId > 0 && (!first || done))
          {
            currRowId--; //Since next time, we will read the last seen record again
          }
          LOG.info("about to call end events with currRowId = " + currRowId);
          first = false;
          _bootstrapSeedWriter.endEvents(currRowId,timestamp,null);
          isException = false;
        } catch (SQLException ex) {
          LOG.error("Got SQLException for source (" + sourceInfo + ")", ex);

          _bootstrapSeedWriter.rollbackEvents();

          numRetry++;
          isException = true;

          if (numRetry >= retryMax)
          {
            throw new DatabusException("Error: Reached max retries for reading/processing bootstrap", ex);
          }
        } finally {
          DBHelper.close(rs);
          rs = null;
        }
View Full Code Here

      super.processCommandLineArgs(cliArgs);
      CommandLine cmdLine = getCmdLine();

      if (! cmdLine.hasOption(ACTION_OPTION_CHAR))
      {
        throw new DatabusException("action expected; see --help for usage");
      }
      String actionString = cmdLine.getOptionValue(ACTION_OPTION_CHAR).toUpperCase();

      try
      {
        _action = Action.valueOf(actionString);
      }
      catch (IllegalArgumentException e)
      {
        throw new DatabusException("invalid action: " + actionString);
      }

      if (_action.equals(Action.CREATE_LOG_TABLE) || _action.equals(Action.CREATE_TAB_TABLE))
      {
        if (! cmdLine.hasOption(SRCID_OPTION_CHAR))
        {
          throw new DatabusException("srcid expected; see --help for usage");
        }
        String srcidString = cmdLine.getOptionValue(SRCID_OPTION_CHAR);

        try
        {
          _srcId = Integer.parseInt(srcidString);
        }
        catch (NumberFormatException e)
        {
          throw new DatabusException("invalid srcid: " + srcidString);
        }
      }
    }
View Full Code Here

        _bootstrapEventBuffer.endEvents(BootstrapEventBuffer.END_OF_SOURCE, endScn, null);
        summaries.add(summary);
      }
      } catch (Exception ex) {
      error = true;
      throw new DatabusException(ex);
      } finally {
       // Notify writer that I am done
      if ( error )
      {
        _bootstrapEventBuffer.endEvents(BootstrapEventBuffer.ERROR_CODE, endScn,null);
View Full Code Here

        {
          if (null == _currentParser)
          {
            returnError(ctx.getChannel(),
                        ErrorResponse.createInternalServerErrorResponse(
                            new DatabusException("expecting more data but no parser")),
                            buffer, State.EXPECT_COMMAND,
                            true,
                            true);
          }
          else
          {
            try
            {
              BinaryCommandParser.ParseResult parseResult = _currentParser.parseBinary(buffer);
              switch (parseResult)
              {
                case DISCARD:  { /* do nothing */ break; }
                case INCOMPLETE_DATA: {_state = State.INCOMPLETE_DATA; break;}
                case EXPECT_MORE:  { _state = State.EXPECT_MORE_DATA; break; }
                case PASS_THROUGH: { result = buffer; break; }
                case DONE:
                  {
                    if (null == _currentParser.getError())
                    {
                      result = _currentParser.getCommand();
                      _state = State.EXPECT_COMMAND;
                    }
                    else
                    {
                      returnError(ctx.getChannel(),
                                  _currentParser.getError(),
                                  buffer, State.EXPECT_COMMAND,
                                  true,
                                  true);
                    }
                    break;
                  }
                default:
                {
                  returnError(ctx.getChannel(),
                              ErrorResponse.createInternalServerErrorResponse(
                                  new DatabusException("unknown parser return code" + parseResult)),
                              buffer, State.EXPECT_COMMAND,
                              true,
                              true);
                }
              }
            }
            catch (UnsupportedProtocolVersionException upve)
            {
              returnError(ctx.getChannel(),
                          ErrorResponse.createUnsupportedProtocolVersionResponse(upve.getProtocolVerson()),
                          buffer, State.EXPECT_COMMAND,
                          true,
                          true);
            }
            catch (Exception ex)
            {
              returnError(ctx.getChannel(),
                          ErrorResponse.createInternalServerErrorResponse(ex),
                          buffer, State.EXPECT_COMMAND,
                          true,
                          true);
            }
          }

          break;
        }
        default:
        {
          returnError(ctx.getChannel(),
                      ErrorResponse.createInternalServerErrorResponse(
                          new DatabusException("unknown state: " + _state)),
                      buffer, State.EXPECT_COMMAND,
                      true,
                      true);
        }
      }
View Full Code Here

          }
        }
        _writer.flush();
      } catch (IOException e) {
        LOG.error("Got Exception :", e);
        throw new DatabusException(e);
      }
      return true;
    }
View Full Code Here

      _registeredMbeans.add(objectName);
    }
    catch(Exception ex)
    {
      _log.error("Failed to register the GGparser statistics mbean for db = " + _pConfig.getName() + " due to an exception.", ex);
      throw new DatabusException("Failed to initialize GGparser statistics mbean.", ex);
    }

  }
View Full Code Here

TOP

Related Classes of com.linkedin.databus2.core.DatabusException

Copyright © 2018 www.massapicom. 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.