forked from kiritbasu/datacollector
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SDC-9186: Service: Add additional whole file format methods to genera…
…tor service SDC side of API-221. Change-Id: I10bb933527c023c07c68bb6785843abc5ed5de58 Reviewed-on: https://review.streamsets.net/14932 Reviewed-by: Santhosh Kumar <santhosh@streamsets.com>
- Loading branch information
Showing
6 changed files
with
221 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
98 changes: 98 additions & 0 deletions
98
...main/java/com/streamsets/pipeline/sdk/service/SdkWholeFileDataFormatGeneratorService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
/* | ||
* Copyright 2018 StreamSets Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.streamsets.pipeline.sdk.service; | ||
|
||
import com.streamsets.pipeline.api.Record; | ||
import com.streamsets.pipeline.api.StageException; | ||
import com.streamsets.pipeline.api.base.BaseService; | ||
import com.streamsets.pipeline.api.service.ServiceDef; | ||
import com.streamsets.pipeline.api.service.dataformats.DataFormatGeneratorService; | ||
import com.streamsets.pipeline.api.service.dataformats.DataGenerator; | ||
import com.streamsets.pipeline.api.service.dataformats.WholeFileChecksumAlgorithm; | ||
import com.streamsets.pipeline.api.service.dataformats.WholeFileExistsAction; | ||
|
||
import java.io.IOException; | ||
import java.io.OutputStream; | ||
|
||
@ServiceDef( | ||
provides = DataFormatGeneratorService.class, | ||
version = 1, | ||
label = "(Test) Runner implementation of very simple DataFormatGeneratorService that will always work with whole file format." | ||
) | ||
public class SdkWholeFileDataFormatGeneratorService extends BaseService implements DataFormatGeneratorService { | ||
|
||
private String wholeFileNamePath; | ||
private WholeFileExistsAction existsAction; | ||
private boolean includeChecksumInTheEvents; | ||
private WholeFileChecksumAlgorithm checksumAlgorithm; | ||
|
||
public SdkWholeFileDataFormatGeneratorService() { | ||
this("/fileName", WholeFileExistsAction.OVERWRITE, false, WholeFileChecksumAlgorithm.MD5); | ||
} | ||
|
||
public SdkWholeFileDataFormatGeneratorService( | ||
String wholeFileNamePath, | ||
WholeFileExistsAction existsAction, | ||
boolean includeChecksumInTheEvents, | ||
WholeFileChecksumAlgorithm checksumAlgorithm | ||
) { | ||
this.wholeFileNamePath = wholeFileNamePath; | ||
this.existsAction = existsAction; | ||
this.includeChecksumInTheEvents = includeChecksumInTheEvents; | ||
this.checksumAlgorithm = checksumAlgorithm; | ||
} | ||
|
||
|
||
@Override | ||
public DataGenerator getGenerator(OutputStream os) throws IOException { | ||
throw new UnsupportedOperationException("Only Whole File Format is supported"); | ||
} | ||
|
||
@Override | ||
public boolean isPlainTextCompatible() { | ||
throw new UnsupportedOperationException("Only Whole File Format is supported"); | ||
} | ||
|
||
@Override | ||
public String getCharset() { | ||
throw new UnsupportedOperationException("Only Whole File Format is supported"); | ||
} | ||
|
||
@Override | ||
public boolean isWholeFileFormat() { | ||
return true; | ||
} | ||
|
||
@Override | ||
public String wholeFileFilename(Record record) throws StageException { | ||
return record.get(wholeFileNamePath).getValueAsString(); | ||
} | ||
|
||
@Override | ||
public WholeFileExistsAction wholeFileExistsAction() { | ||
return existsAction; | ||
} | ||
|
||
@Override | ||
public boolean wholeFileIncludeChecksumInTheEvents() { | ||
return includeChecksumInTheEvents; | ||
} | ||
|
||
@Override | ||
public WholeFileChecksumAlgorithm wholeFileChecksumAlgorithm() { | ||
return checksumAlgorithm; | ||
} | ||
} |