Package com.linkedin.databus2.core

Examples of com.linkedin.databus2.core.DatabusException


  {
    GenericRecord record = new GenericData.Record(getCurrentSchema());
    List<Schema.Field> fields = getCurrentSchema().getFields();
    String pkFieldName = SchemaHelper.getMetaField(getCurrentSchema(), "pk");
    if(pkFieldName == null)
      throw new DatabusException("No primary key specified in the schema");
    PrimaryKey pk = new PrimaryKey(pkFieldName);
    for(Schema.Field field : fields)
    {
      if(field.schema().getType() == Schema.Type.ARRAY)
      {
        throw new DatabusException("The gg parser cannot handle ARRAY datatypes. Found in field: "+ field);
      }
      else
      {
        //The current database field being processed (field is avro field name  and databaseFieldName is oracle field name (one to one mapping)
        String databaseFieldName = SchemaHelper.getMetaField(field, "dbFieldName");
View Full Code Here


      throws DatabusException
  {
    if(eventFields.get(databaseFieldName).isKey())
    {
      if (!pk.isPartOfPrimaryKey(field))
        throw new DatabusException("The primary key is not as expected. Expected: " + pkFieldName + " found from xml: " + field.name());
      if(fieldValueObj == null)
        throw new DatabusException("Unable to find the value of the object");
      Schema.Type pkFieldType = SchemaHelper.unwindUnionSchema(field).getType();
      KeyPair pair = new KeyPair(fieldValueObj, pkFieldType);
      _keyPairs.add(pair);
    }
  }
View Full Code Here

      LOG.error("Missing field "+ databaseFieldName + " in event from the xml trail for table " + _currentTable);
      if(!_errorOnMissingFields)   //Are we ok to accept null fields ?
      {
        //We cannot tolerate empty primary key fields, so we'll throw exception if key is null
        if (pk.isPartOfPrimaryKey(field))
          throw new DatabusException("Skip errors on missing DB Fields is true, but cannot proceed because primary key not found: " + field.name());

        //We also need the replication field, it's not optional if MissingValueBehavior == STOP_WITH_ERROR
        if(replicationBitConfig.getSourceType() == ReplicationBitSetterStaticConfig.SourceType.COLUMN
            && isReplicationField(databaseFieldName, replicationBitConfig)
            && replicationBitConfig.getMissingValueBehavior() == MissingValueBehavior.STOP_WITH_ERROR)
        {
          throw new DatabusException("Skip errors on missing DB Fields is true, but the replication field is missing, this is mandatory, cannot proceed with  " + field.name()+ " field missing");
        }

        setSeenMissingFields(true);
        //If not primary key, we create fake hash entry with a null eventfield entry
        ColumnState.EventField emptyEventField = new ColumnState.EventField(false, null, true);
        eventFields.put(databaseFieldName, emptyEventField);
      }
      else
        throw new DatabusException("Unable to find a required field " + databaseFieldName + " in the xml trail file");
    }
  }
View Full Code Here

      LOG.info("Resetting Catchup Target Max Scn !!");
      _producer.setCatchupTargetMaxScn(-1);
      String result = "{ \"command\" : \"" + command + "\", \"result\" : \"true\" }";     
      request.getResponseContent().write(ByteBuffer.wrap(result.getBytes(Charset.defaultCharset())));
    else {
      throw new DatabusException("Unknown command :" + command);
    }

    return request;
  }
View Full Code Here

    _tableToNamespace = new HashMap<String, String>();
    _tableToSourceId = new HashMap<String, Integer>();

    if(sources.length == 0)
    {
      throw new DatabusException("No logical sources found! Nothing to capture here.");
    }

    for(int i = 0 ; i< sources.length ; i++)
    {
      String tableName = sources[i].getUri();
View Full Code Here

    catch(SQLException ex)
    {
        try {
             DBHelper.rollback(_eventSelectConnection);
         } catch (SQLException s) {
             throw new DatabusException(s.getMessage());
         };

          handleExceptionInReadEvents(ex);
          throw new DatabusException(ex);
    }
    catch(Exception e)
    {
      handleExceptionInReadEvents(e);
      throw new DatabusException(e);
    }
    finally
    {
      // If events were not processed successfully then eventBufferNeedsRollback will be true.
      // If that happens, rollback the event buffer.
View Full Code Here

    }

    if(scn == TokenState.ERRORSCN)
    {
      LOG.error("Unable to find scn for the given dbUpdate");
      throw new DatabusException("Unable to find scn for the given dbUpdate, terminating the parser");
    }

    //check if the current columns state has seen any missing elements, if it has, then print the current scn associated with the dbupdate for debugging purpose
    if(stateMachine.columnsState.isSeenMissingFields())
    {
      LOG.error("There were missing fields seen in Columns section and the corresponding scn is : " + stateMachine.tokensState.getScn());
    }

    Boolean isReplicated = false;
    if(stateMachine.getReplicationBitConfig().getSourceType() == ReplicationBitSetterStaticConfig.SourceType.COLUMN)
      isReplicated = stateMachine.columnsState.isReplicated();
    else if(stateMachine.getReplicationBitConfig().getSourceType() == ReplicationBitSetterStaticConfig.SourceType.TOKEN)
      isReplicated = stateMachine.tokensState.isReplicated();
    else if(stateMachine.getReplicationBitConfig().getSourceType() == ReplicationBitSetterStaticConfig.SourceType.NONE)
      isReplicated = false;
    else
      throw new DatabusException("Unknown source type specified in replicationBitConfig, expected COLUMN or TOKEN or NONE");

    DBUpdateImage eventImage = new DBUpdateImage(stateMachine.columnsState.getKeyPairs(),
                                                 stateMachine.tokensState.getScn(),
                                                 stateMachine.columnsState.getGenericRecord(),
                                                 stateMachine.columnsState.getCurrentSchema(),
                                                 _opType,
                                                 isReplicated);
    Integer sourceId = stateMachine.getTableToSourceId().get(_currentTable);
    if(sourceId == null)
    {
      LOG.error("The table " + _currentTable + " does not have a sourceId, the current dbUpdate cannot be processed.");
      onError(stateMachine, xmlStreamReader);
      return;
    }

    if(getHashSet(sourceId) == null)
    {
      LOG.error("The hashset is empty, cannot proceed without a valid hashset");
      throw new DatabusException("Error while creating hashset for storing dbUpdates");
    }

    //The equals method of the hashset is overridden to compare only the key, thereby ensuring the latest update on the key
    if(getHashSet(sourceId) != null && getHashSet(sourceId).contains(eventImage))
      getHashSet(sourceId).remove(eventImage);
View Full Code Here

    }

    if(_currentTable == null || _currentTable.length() == 0)
    {
      LOG.fatal("PROBLEM WITH XML: Dbupdate does not have any table name associated with it, stopping ");
      throw new DatabusException("Dbupdate does not have any table name associated with it, stopping");
    }

    Schema schema = StateMachineHelper.tableToSchema(_currentTable, stateMachine.getTableToSourceNameMap(), stateMachine.getSchemaRegistryService());
    if(schema == null)
    {
View Full Code Here

                         OpType opType,
                         boolean isReplicatedFlag)
        throws DatabusException
    {
      if(keyPairs.size() == 0)
        throw new DatabusException("Unable to construct DBUpdateImage because no keys were found");

      if(opType == OpType.UNKNOWN)
        throw new DatabusException("Unknown operation type, INSERT/UPDATE/DELETE not set?");
      _keyPairs = keyPairs;
      _scn = scn;
      _genericRecord = genericRecord;
      _schema = schema;
      _opType = opType;
View Full Code Here

    _currentStateType = STATETYPE.ENDELEMENT;
    if(LOG.isDebugEnabled())
       LOG.debug("The current transaction has " + stateMachine.dbUpdateState.getSourceDbUpdatesMap().size() + " DbUpdates");
    if(_transactionSuccessCallBack == null)
    {
      throw new DatabusException("No callback specified for the transaction state! Cannot proceed without a callback");
    }

    long endTransactionLocation = xmlStreamReader.getLocation().getCharacterOffset();
    _transactionSize =  endTransactionLocation - _startTransLocation;
    // collect stats
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.