forked from hiero-ledger/hiero-mirror-node
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Apply latest origin master commits (#93)
* Fix the issue gRPC notify thread blocked (hiero-ledger#965) Add backpressure buffer with ERROR strategy to notifying and shared polling topic listeners. When overflow happens, the controller will send a gRPC error after all buffered messages and disconnect the client. Signed-off-by: Xin Li <[email protected]> * Performance test HighTPS HCS publish improvements (hiero-ledger#970) * Performance updates to high tps module - Adds additional stats - Allow publish of stats interval to be configured - Does some reorganizing of code - Sets JMeter and java flags to allow for improved publish performance and prevent memory exhaustion Signed-off-by: Nana-EC <[email protected]> * Bump spring-boot-starter-parent from 2.2.7.RELEASE to 2.3.3.RELEASE (hiero-ledger#961) Bumps [spring-boot-starter-parent](https://github.com/spring-projects/spring-boot) from 2.2.7.RELEASE to 2.3.3.RELEASE. - [Release notes](https://github.com/spring-projects/spring-boot/releases) - [Commits](spring-projects/spring-boot@v2.2.7.RELEASE...v2.3.3.RELEASE) Signed-off-by: Nana-EC <[email protected]> Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Xin Li <[email protected]> Co-authored-by: Nana-EC <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
- Loading branch information
1 parent
5216bc0
commit 61620de
Showing
19 changed files
with
329 additions
and
116 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
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
147 changes: 147 additions & 0 deletions
147
hedera-mirror-grpc/src/test/java/com/hedera/mirror/grpc/jmeter/handler/SDKClientHandler.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,147 @@ | ||
package com.hedera.mirror.grpc.jmeter.handler; | ||
|
||
/*- | ||
* | ||
* Hedera Mirror Node | ||
* | ||
* Copyright (C) 2019 - 2020 Hedera Hashgraph, LLC | ||
* | ||
* 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. | ||
* | ||
*/ | ||
|
||
import java.time.Duration; | ||
import java.time.Instant; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.concurrent.TimeUnit; | ||
import java.util.concurrent.TimeoutException; | ||
import java.util.concurrent.atomic.AtomicInteger; | ||
import lombok.AccessLevel; | ||
import lombok.Getter; | ||
import lombok.Value; | ||
import lombok.extern.log4j.Log4j2; | ||
|
||
import com.hedera.hashgraph.sdk.Client; | ||
import com.hedera.hashgraph.sdk.HederaStatusException; | ||
import com.hedera.hashgraph.sdk.Status; | ||
import com.hedera.hashgraph.sdk.Transaction; | ||
import com.hedera.hashgraph.sdk.TransactionId; | ||
import com.hedera.hashgraph.sdk.TransactionReceipt; | ||
import com.hedera.hashgraph.sdk.account.AccountId; | ||
import com.hedera.hashgraph.sdk.account.CryptoTransferTransaction; | ||
import com.hedera.hashgraph.sdk.consensus.ConsensusMessageSubmitTransaction; | ||
import com.hedera.hashgraph.sdk.consensus.ConsensusTopicCreateTransaction; | ||
import com.hedera.hashgraph.sdk.consensus.ConsensusTopicId; | ||
import com.hedera.hashgraph.sdk.crypto.ed25519.Ed25519PrivateKey; | ||
import com.hedera.mirror.grpc.jmeter.props.NodeInfo; | ||
|
||
@Log4j2 | ||
@Value | ||
public class SDKClientHandler { | ||
protected final Client client; | ||
private final NodeInfo nodeInfo; | ||
private final AccountId operatorId; | ||
@Getter(AccessLevel.NONE) | ||
private final Ed25519PrivateKey operatorPrivateKey; | ||
|
||
public SDKClientHandler(String nodeParts, AccountId operatorId, Ed25519PrivateKey operatorPrivateKey) { | ||
nodeInfo = new NodeInfo(nodeParts); | ||
this.operatorId = operatorId; | ||
this.operatorPrivateKey = operatorPrivateKey; | ||
|
||
client = new Client(Map.of(nodeInfo.getNodeId(), nodeInfo.getNodeAddress())); | ||
client.setOperator(operatorId, operatorPrivateKey); | ||
|
||
log.trace("Created client for {}", nodeInfo); | ||
} | ||
|
||
public void close() throws InterruptedException { | ||
log.debug("Closing SDK client, waits up to 10 s for valid close"); | ||
|
||
try { | ||
if (client != null) { | ||
client.close(5, TimeUnit.SECONDS); | ||
} | ||
} catch (TimeoutException tex) { | ||
log.debug("Exception on client close: {}", tex.getMessage()); | ||
} | ||
} | ||
|
||
public ConsensusTopicId createTopic() throws HederaStatusException { | ||
|
||
ConsensusTopicCreateTransaction consensusTopicCreateTransaction = new ConsensusTopicCreateTransaction() | ||
.setAdminKey(operatorPrivateKey.publicKey) | ||
.setAutoRenewAccountId(operatorId) | ||
.setMaxTransactionFee(1_000_000_000) | ||
.setTopicMemo("HCS Topic_" + Instant.now()); | ||
|
||
return createTopic(consensusTopicCreateTransaction); | ||
} | ||
|
||
public ConsensusTopicId createTopic(ConsensusTopicCreateTransaction consensusTopicCreateTransaction) throws HederaStatusException { | ||
TransactionReceipt transactionReceipt = consensusTopicCreateTransaction | ||
.execute(client) | ||
.getReceipt(client); | ||
|
||
ConsensusTopicId topicId = transactionReceipt.getConsensusTopicId(); | ||
log.info("Created new topic {}, with TransactionReceipt : {}", topicId, transactionReceipt); | ||
|
||
return topicId; | ||
} | ||
|
||
public TransactionId submitTopicMessage(ConsensusTopicId topicId, String message) throws HederaStatusException { | ||
ConsensusMessageSubmitTransaction consensusMessageSubmitTransaction = new ConsensusMessageSubmitTransaction() | ||
.setTopicId(topicId) | ||
.setMessage(message); | ||
|
||
return submitTopicMessage(consensusMessageSubmitTransaction); | ||
} | ||
|
||
public TransactionId submitTopicMessage(ConsensusMessageSubmitTransaction consensusMessageSubmitTransaction) throws HederaStatusException { | ||
Transaction transaction = consensusMessageSubmitTransaction.build(client); | ||
|
||
return transaction.execute(client, Duration.ofSeconds(2)); | ||
} | ||
|
||
public TransactionId submitCryptoTransfer(AccountId operatorId, AccountId recipientId, int amount) throws HederaStatusException { | ||
TransactionId transactionId = new CryptoTransferTransaction() | ||
.addSender(operatorId, amount) | ||
.addRecipient(recipientId, amount) | ||
.setTransactionMemo("transfer test") | ||
.execute(client); | ||
|
||
return transactionId; | ||
} | ||
|
||
public int getValidTransactionsCount(List<TransactionId> transactionIds) { | ||
log.debug("Verify Transactions {}", transactionIds.size()); | ||
AtomicInteger counter = new AtomicInteger(0); | ||
transactionIds.forEach(x -> { | ||
TransactionReceipt receipt = null; | ||
try { | ||
receipt = x.getReceipt(client); | ||
} catch (HederaStatusException e) { | ||
log.debug("Error pulling {} receipt {}", x, e.getMessage()); | ||
} | ||
if (receipt.status == Status.Success) { | ||
counter.incrementAndGet(); | ||
} else { | ||
log.warn("Transaction {} had an unexpected status of {}", x, receipt.status); | ||
} | ||
}); | ||
|
||
log.debug("{} out of {} transactions returned a Success status", counter.get(), transactionIds.size()); | ||
return counter.get(); | ||
} | ||
} |
Oops, something went wrong.