/** * Compares using the target steps and copy, not the source. * That way, re-partitioning is always done in the same way. */ @Override public int compareTo( RowSet rowSet ) { lock.readLock().lock(); String target; try { target = remoteSlaveServerName + "." + destinationStepName + "." + destinationStepCopy.intValue(); } finally { lock.readLock().unlock(); } String comp = rowSet.getRemoteSlaveServerName() + "." + rowSet.getDestinationStepName() + "." + rowSet.getDestinationStepCopy(); return target.compareTo( comp ); }
/** * Finds the RowSet between two steps (or copies of steps). * * @param from the name of the "from" step * @param fromcopy the copy number of the "from" step * @param to the name of the "to" step * @param tocopy the copy number of the "to" step * @return the row set, or null if none found */ public RowSet findRowSet( String from, int fromcopy, String to, int tocopy ) { // Start with the transformation. for ( int i = 0; i < rowsets.size(); i++ ) { RowSet rs = rowsets.get( i ); if ( rs.getOriginStepName().equalsIgnoreCase( from ) && rs.getDestinationStepName().equalsIgnoreCase( to ) && rs .getOriginStepCopy() == fromcopy && rs.getDestinationStepCopy() == tocopy ) { return rs; } } return null; }
@Override public void identifyErrorOutput() { if ( stepMeta.isDoingErrorHandling() ) { StepErrorMeta stepErrorMeta = stepMeta.getStepErrorMeta(); outputRowSetsLock.writeLock().lock(); try { for ( int rowsetNr = 0; rowsetNr < outputRowSets.size(); rowsetNr++ ) { RowSet outputRowSet = outputRowSets.get( rowsetNr ); if ( outputRowSet.getDestinationStepName().equalsIgnoreCase( stepErrorMeta.getTargetStep().getName() ) ) { // This is the rowset to move! // errorRowSet = outputRowSet; outputRowSets.remove( rowsetNr ); return; } } } finally { outputRowSetsLock.writeLock().unlock(); } } }
for ( RowSet rs : inputRowSets ) { if ( rs.getOriginStepName().equalsIgnoreCase( from ) && rs.getDestinationStepName().equalsIgnoreCase( to ) && rs.getOriginStepCopy() == fromcopy && rs.getDestinationStepCopy() == tocopy ) { return rs; if ( rs.getDestinationStepName().equalsIgnoreCase( to ) ) { return rs;
for ( RowSet rs : outputRowSets ) { if ( rs.getOriginStepName().equalsIgnoreCase( from ) && rs.getDestinationStepName().equalsIgnoreCase( to ) && rs.getOriginStepCopy() == fromcopy && rs.getDestinationStepCopy() == tocopy ) { return rs;
Mockito.when( rowSet.getDestinationStepName() ).thenReturn( "Validator" ); Mockito.when( rowSet.getOriginStepCopy() ).thenReturn( 0 ); Mockito.when( rowSet.getDestinationStepCopy() ).thenReturn( 0 );
private RowSet mockLookupRowSet( boolean binary ) { final int storageType = binary ? ValueMetaInterface.STORAGE_TYPE_BINARY_STRING : ValueMetaInterface.STORAGE_TYPE_NORMAL; Object[][] data = { { "Value1", "1" }, { "Value2", "2" } }; if ( binary ) { convertDataToBinary( data ); } RowSet lookupRowSet = smh.getMockInputRowSet( data ); doReturn( "Lookup" ).when( lookupRowSet ).getOriginStepName(); doReturn( "StreamLookup" ).when( lookupRowSet ).getDestinationStepName(); RowMeta lookupRowMeta = new RowMeta(); ValueMetaString valueMeta = new ValueMetaString( "Value" ); valueMeta.setStorageType( storageType ); valueMeta.setStorageMetadata( new ValueMetaString() ); lookupRowMeta.addValueMeta( valueMeta ); ValueMetaString idMeta = new ValueMetaString( "Id" ); idMeta.setStorageType( storageType ); idMeta.setStorageMetadata( new ValueMetaString() ); lookupRowMeta.addValueMeta( idMeta ); doReturn( lookupRowMeta ).when( lookupRowSet ).getRowMeta(); return lookupRowSet; }