This repository has been archived by the owner on May 12, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 152
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
APEXMALHAR-2515. Added support for writing into multiple HBase tables.
- Loading branch information
1 parent
712027a
commit a725639
Showing
9 changed files
with
447 additions
and
135 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
86 changes: 86 additions & 0 deletions
86
contrib/src/main/java/com/datatorrent/contrib/hbase/AbstractHBaseOutputOperator.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,86 @@ | ||
/** | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you 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.datatorrent.contrib.hbase; | ||
|
||
import org.apache.hadoop.hbase.client.HTable; | ||
|
||
import com.datatorrent.api.Operator; | ||
import com.datatorrent.lib.db.AbstractStoreOutputOperator; | ||
|
||
/** | ||
* A base implementation of a HBase output operator that stores tuples in HBase and offers | ||
* non-transactional Insert. Subclasses should provide implementation for specific Hbase operations. | ||
*/ | ||
public abstract class AbstractHBaseOutputOperator<T> extends AbstractStoreOutputOperator<T, HBaseStore> implements OutputAdapter.Driver<T>, Operator.CheckpointNotificationListener | ||
{ | ||
private transient OutputAdapter<T> outputAdapter; | ||
|
||
public AbstractHBaseOutputOperator() | ||
{ | ||
outputAdapter = new OutputAdapter<T>(store, this); | ||
} | ||
|
||
@Override | ||
public void processTuple(T tuple) | ||
{ | ||
outputAdapter.processTuple(tuple); | ||
} | ||
|
||
@Override | ||
public abstract void processTuple(T tuple, HTable table); | ||
|
||
/** | ||
* Get the table name for tuple. | ||
* | ||
* Implementations can override this method to return the table name where the tuple should be written to. | ||
* Return null to write to default table | ||
* @param tuple The tuple | ||
* @return The table name | ||
*/ | ||
@Override | ||
public String getTableName(T tuple) | ||
{ | ||
return null; | ||
} | ||
|
||
@Override | ||
public void errorTuple(T tuple) | ||
{ | ||
|
||
} | ||
|
||
@Override | ||
public void beforeCheckpoint(long l) | ||
{ | ||
outputAdapter.flushTuples(); | ||
} | ||
|
||
@Override | ||
public void checkpointed(long l) | ||
{ | ||
|
||
} | ||
|
||
@Override | ||
public void committed(long l) | ||
{ | ||
|
||
} | ||
|
||
} |
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
Oops, something went wrong.