forked from pinpoint-apm/pinpoint
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[pinpoint-apm#8691] Separate hbase connection for batch operation
- Loading branch information
Showing
7 changed files
with
121 additions
and
60 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
22 changes: 22 additions & 0 deletions
22
...ns-hbase/src/main/java/com/navercorp/pinpoint/common/hbase/batch/AsyncTemplateWriter.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,22 @@ | ||
package com.navercorp.pinpoint.common.hbase.batch; | ||
|
||
import com.navercorp.pinpoint.common.hbase.HbaseOperations2; | ||
import com.navercorp.pinpoint.common.hbase.SimpleBatchWriter; | ||
import org.apache.hadoop.hbase.TableName; | ||
import org.apache.hadoop.hbase.client.Put; | ||
|
||
import java.util.Objects; | ||
|
||
public class AsyncTemplateWriter implements SimpleBatchWriter { | ||
private final HbaseOperations2 hbaseOperations2; | ||
|
||
public AsyncTemplateWriter(HbaseOperations2 hbaseOperations2) { | ||
this.hbaseOperations2 = Objects.requireNonNull(hbaseOperations2, "hbaseOperations2"); | ||
|
||
} | ||
|
||
@Override | ||
public boolean write(TableName tableName, Put mutation) { | ||
return hbaseOperations2.asyncPut(tableName, mutation); | ||
} | ||
} |
34 changes: 0 additions & 34 deletions
34
...se/src/main/java/com/navercorp/pinpoint/common/hbase/batch/DelegateSimpleBatchWriter.java
This file was deleted.
Oops, something went wrong.
40 changes: 40 additions & 0 deletions
40
...src/main/java/com/navercorp/pinpoint/common/hbase/batch/SimpleBatchWriterFactoryBean.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,40 @@ | ||
package com.navercorp.pinpoint.common.hbase.batch; | ||
|
||
import com.navercorp.pinpoint.common.hbase.HbaseOperations2; | ||
import com.navercorp.pinpoint.common.hbase.SimpleBatchWriter; | ||
import org.apache.hadoop.hbase.TableName; | ||
import org.apache.hadoop.hbase.client.Put; | ||
import org.springframework.beans.factory.FactoryBean; | ||
import org.springframework.beans.factory.annotation.Qualifier; | ||
|
||
import java.util.Objects; | ||
|
||
public class SimpleBatchWriterFactoryBean implements FactoryBean<SimpleBatchWriter> { | ||
|
||
private final SimpleBatchWriter batchWriter; | ||
|
||
public SimpleBatchWriterFactoryBean(BufferedMutatorConfiguration configuration, | ||
HbaseBatchWriter hbaseBatchWriter, | ||
@Qualifier("asyncPutHbaseTemplate") HbaseOperations2 hbaseTemplate) { | ||
if (configuration.isBatchWriter()) { | ||
this.batchWriter = new SimpleBufferWriter(hbaseBatchWriter); | ||
} else { | ||
this.batchWriter = new AsyncTemplateWriter(hbaseTemplate); | ||
} | ||
} | ||
|
||
@Override | ||
public SimpleBatchWriter getObject() throws Exception { | ||
return batchWriter; | ||
} | ||
|
||
@Override | ||
public Class<?> getObjectType() { | ||
return SimpleBatchWriter.class; | ||
} | ||
|
||
@Override | ||
public boolean isSingleton() { | ||
return true; | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
...ons-hbase/src/main/java/com/navercorp/pinpoint/common/hbase/batch/SimpleBufferWriter.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,20 @@ | ||
package com.navercorp.pinpoint.common.hbase.batch; | ||
|
||
import com.navercorp.pinpoint.common.hbase.SimpleBatchWriter; | ||
import org.apache.hadoop.hbase.TableName; | ||
import org.apache.hadoop.hbase.client.Put; | ||
|
||
import java.util.Objects; | ||
|
||
public class SimpleBufferWriter implements SimpleBatchWriter { | ||
private final HbaseBatchWriter batchWriter; | ||
|
||
public SimpleBufferWriter(HbaseBatchWriter batchWriter) { | ||
this.batchWriter = Objects.requireNonNull(batchWriter, "batchWriter"); | ||
} | ||
|
||
@Override | ||
public boolean write(TableName tableName, Put mutation) { | ||
return batchWriter.write(tableName, mutation); | ||
} | ||
} |