Search in sources :

Example 16 with AddressBookEntry

use of com.hedera.mirror.common.domain.addressbook.AddressBookEntry in project hedera-mirror-node by hashgraph.

the class AddAddressBookServiceEndpointsMigrationTest method verifyMigrateWhenNeitherDeprecatedIpNorAddressBookServiceEndpointsAreSet.

@Test
void verifyMigrateWhenNeitherDeprecatedIpNorAddressBookServiceEndpointsAreSet() throws IOException {
    long consensusTimestamp = 1;
    int nodeIdCount = 3;
    int endPointPerNode = 0;
    insertAddressBook(AddressBookServiceImpl.ADDRESS_BOOK_102_ENTITY_ID, consensusTimestamp, nodeIdCount);
    getAndSaveAddressBookEntries(false, consensusTimestamp, nodeIdCount, endPointPerNode);
    assertThat(addressBookEntryRepository.count()).isEqualTo(nodeIdCount);
    runMigration();
    assertThat(addressBookEntryRepository.findAll()).isNotEmpty().hasSize(nodeIdCount).extracting(AddressBookEntry::getId).extracting(AddressBookEntry.Id::getNodeId).containsExactlyInAnyOrder(0L, 1L, 2L);
    assertThat(addressBookServiceEndpointRepository.findAll()).isEmpty();
}
Also used : AddressBookEntry(com.hedera.mirror.common.domain.addressbook.AddressBookEntry) AddressBookServiceEndpoint(com.hedera.mirror.common.domain.addressbook.AddressBookServiceEndpoint) Test(org.junit.jupiter.api.Test) IntegrationTest(com.hedera.mirror.importer.IntegrationTest)

Example 17 with AddressBookEntry

use of com.hedera.mirror.common.domain.addressbook.AddressBookEntry in project hedera-mirror-node by hashgraph.

the class NetworkServiceTest method moreThanPageSize.

@Test
void moreThanPageSize() {
    addressBookProperties.setPageSize(2);
    AddressBook addressBook = addressBook();
    AddressBookEntry addressBookEntry1 = addressBookEntry();
    AddressBookEntry addressBookEntry2 = addressBookEntry();
    AddressBookEntry addressBookEntry3 = addressBookEntry();
    AddressBookFilter filter = AddressBookFilter.builder().fileId(addressBook.getFileId()).build();
    assertThat(getNodes(filter)).containsExactly(addressBookEntry1, addressBookEntry2, addressBookEntry3);
}
Also used : AddressBookFilter(com.hedera.mirror.grpc.domain.AddressBookFilter) AddressBook(com.hedera.mirror.common.domain.addressbook.AddressBook) AddressBookEntry(com.hedera.mirror.common.domain.addressbook.AddressBookEntry) GrpcIntegrationTest(com.hedera.mirror.grpc.GrpcIntegrationTest) Test(org.junit.jupiter.api.Test)

Example 18 with AddressBookEntry

use of com.hedera.mirror.common.domain.addressbook.AddressBookEntry in project hedera-mirror-node by hashgraph.

the class NetworkServiceTest method limitReached.

@Test
void limitReached() {
    AddressBook addressBook = addressBook();
    AddressBookEntry addressBookEntry1 = addressBookEntry();
    addressBookEntry();
    AddressBookFilter filter = AddressBookFilter.builder().fileId(addressBook.getFileId()).limit(1).build();
    assertThat(getNodes(filter)).containsExactly(addressBookEntry1);
}
Also used : AddressBookFilter(com.hedera.mirror.grpc.domain.AddressBookFilter) AddressBook(com.hedera.mirror.common.domain.addressbook.AddressBook) AddressBookEntry(com.hedera.mirror.common.domain.addressbook.AddressBookEntry) GrpcIntegrationTest(com.hedera.mirror.grpc.GrpcIntegrationTest) Test(org.junit.jupiter.api.Test)

Example 19 with AddressBookEntry

use of com.hedera.mirror.common.domain.addressbook.AddressBookEntry in project hedera-mirror-node by hashgraph.

the class NetworkServiceTest method equalToPageSize.

@Test
void equalToPageSize() {
    addressBookProperties.setPageSize(2);
    AddressBook addressBook = addressBook();
    AddressBookEntry addressBookEntry1 = addressBookEntry();
    AddressBookEntry addressBookEntry2 = addressBookEntry();
    AddressBookFilter filter = AddressBookFilter.builder().fileId(addressBook.getFileId()).build();
    assertThat(getNodes(filter)).containsExactly(addressBookEntry1, addressBookEntry2);
}
Also used : AddressBookFilter(com.hedera.mirror.grpc.domain.AddressBookFilter) AddressBook(com.hedera.mirror.common.domain.addressbook.AddressBook) AddressBookEntry(com.hedera.mirror.common.domain.addressbook.AddressBookEntry) GrpcIntegrationTest(com.hedera.mirror.grpc.GrpcIntegrationTest) Test(org.junit.jupiter.api.Test)

Example 20 with AddressBookEntry

use of com.hedera.mirror.common.domain.addressbook.AddressBookEntry in project hedera-mirror-node by hashgraph.

the class AddressBookServiceImpl method retrieveNodeAddressesFromAddressBook.

/**
 * Extracts a collection of AddressBookEntry domain objects from NodeAddressBook proto. Sets provided
 * consensusTimestamp as the consensusTimestamp of each address book entry to ensure mapping to a single
 * AddressBook
 *
 * @param nodeAddressBook    node address book proto
 * @param consensusTimestamp transaction consensusTimestamp
 * @return
 */
private static Collection<AddressBookEntry> retrieveNodeAddressesFromAddressBook(NodeAddressBook nodeAddressBook, long consensusTimestamp) throws UnknownHostException {
    // node id to entry
    Map<Long, AddressBookEntry> addressBookEntries = new LinkedHashMap<>();
    for (NodeAddress nodeAddressProto : nodeAddressBook.getNodeAddressList()) {
        Pair<Long, EntityId> nodeIds = getNodeIds(nodeAddressProto);
        AddressBookEntry addressBookEntry = addressBookEntries.computeIfAbsent(nodeIds.getLeft(), k -> getAddressBookEntry(nodeAddressProto, consensusTimestamp, nodeIds));
        Set<AddressBookServiceEndpoint> updatedList = new HashSet<>(addressBookEntry.getServiceEndpoints());
        updatedList.addAll(getAddressBookServiceEndpoints(nodeAddressProto, consensusTimestamp));
        addressBookEntry.setServiceEndpoints(updatedList);
    }
    return addressBookEntries.values();
}
Also used : EntityId(com.hedera.mirror.common.domain.entity.EntityId) AddressBookServiceEndpoint(com.hedera.mirror.common.domain.addressbook.AddressBookServiceEndpoint) AddressBookEntry(com.hedera.mirror.common.domain.addressbook.AddressBookEntry) NodeAddress(com.hederahashgraph.api.proto.java.NodeAddress) LinkedHashMap(java.util.LinkedHashMap) HashSet(java.util.HashSet)

Aggregations

AddressBookEntry (com.hedera.mirror.common.domain.addressbook.AddressBookEntry)26 Test (org.junit.jupiter.api.Test)18 AddressBook (com.hedera.mirror.common.domain.addressbook.AddressBook)12 AddressBookServiceEndpoint (com.hedera.mirror.common.domain.addressbook.AddressBookServiceEndpoint)11 GrpcIntegrationTest (com.hedera.mirror.grpc.GrpcIntegrationTest)10 EntityId (com.hedera.mirror.common.domain.entity.EntityId)6 AddressBookFilter (com.hedera.mirror.grpc.domain.AddressBookFilter)6 IntegrationTest (com.hedera.mirror.importer.IntegrationTest)6 NodeAddress (com.hederahashgraph.api.proto.java.NodeAddress)6 ByteString (com.google.protobuf.ByteString)4 AtomicLong (java.util.concurrent.atomic.AtomicLong)4 AddressBookQuery (com.hedera.mirror.api.proto.AddressBookQuery)3 Log4j2 (lombok.extern.log4j.Log4j2)3 ReactorNetworkServiceGrpc (com.hedera.mirror.api.proto.ReactorNetworkServiceGrpc)2 DomainBuilder (com.hedera.mirror.common.domain.DomainBuilder)2 EntityType (com.hedera.mirror.common.domain.entity.EntityType)2 ProtoUtil (com.hedera.mirror.grpc.util.ProtoUtil)2 FileID (com.hederahashgraph.api.proto.java.FileID)2 ServiceEndpoint (com.hederahashgraph.api.proto.java.ServiceEndpoint)2 Status (io.grpc.Status)2