• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

apache / iotdb / #9905

23 Aug 2023 06:20AM UTC coverage: 47.785% (-0.1%) from 47.922%
#9905

push

travis_ci

web-flow
[To rel/1.2][Metric] Fix flush point statistics (#10934)

23 of 23 new or added lines in 1 file covered. (100.0%)

79851 of 167106 relevant lines covered (47.78%)

0.48 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

87.5
/iotdb-core/consensus/src/main/java/org/apache/iotdb/consensus/common/Peer.java
1
/*
2
 * Licensed to the Apache Software Foundation (ASF) under one
3
 * or more contributor license agreements.  See the NOTICE file
4
 * distributed with this work for additional information
5
 * regarding copyright ownership.  The ASF licenses this file
6
 * to you under the Apache License, Version 2.0 (the
7
 * "License"); you may not use this file except in compliance
8
 * with the License.  You may obtain a copy of the License at
9
 *
10
 *     http://www.apache.org/licenses/LICENSE-2.0
11
 *
12
 * Unless required by applicable law or agreed to in writing,
13
 * software distributed under the License is distributed on an
14
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
 * KIND, either express or implied.  See the License for the
16
 * specific language governing permissions and limitations
17
 * under the License.
18
 */
19

20
package org.apache.iotdb.consensus.common;
21

22
import org.apache.iotdb.common.rpc.thrift.TEndPoint;
23
import org.apache.iotdb.commons.consensus.ConsensusGroupId;
24
import org.apache.iotdb.commons.utils.BasicStructureSerDeUtil;
25
import org.apache.iotdb.commons.utils.ThriftCommonsSerDeUtils;
26

27
import org.slf4j.Logger;
28
import org.slf4j.LoggerFactory;
29

30
import java.io.DataOutputStream;
31
import java.io.IOException;
32
import java.nio.ByteBuffer;
33
import java.util.Objects;
34

35
public class Peer {
36

37
  private final Logger logger = LoggerFactory.getLogger(Peer.class);
1✔
38
  private final ConsensusGroupId groupId;
39
  private final TEndPoint endpoint;
40
  private final int nodeId;
41

42
  public Peer(ConsensusGroupId groupId, int nodeId, TEndPoint endpoint) {
1✔
43
    this.groupId = groupId;
1✔
44
    this.nodeId = nodeId;
1✔
45
    this.endpoint = endpoint;
1✔
46
  }
1✔
47

48
  public ConsensusGroupId getGroupId() {
49
    return groupId;
1✔
50
  }
51

52
  public TEndPoint getEndpoint() {
53
    return endpoint;
1✔
54
  }
55

56
  public int getNodeId() {
57
    return nodeId;
1✔
58
  }
59

60
  public void serialize(DataOutputStream stream) {
61
    try {
62
      ThriftCommonsSerDeUtils.serializeTConsensusGroupId(
1✔
63
          groupId.convertToTConsensusGroupId(), stream);
1✔
64
      BasicStructureSerDeUtil.write(nodeId, stream);
1✔
65
      ThriftCommonsSerDeUtils.serializeTEndPoint(endpoint, stream);
1✔
66
    } catch (IOException e) {
×
67
      logger.error("Failed to serialize Peer", e);
×
68
    }
1✔
69
  }
1✔
70

71
  public static Peer deserialize(ByteBuffer buffer) {
72
    return new Peer(
1✔
73
        ConsensusGroupId.Factory.createFromTConsensusGroupId(
1✔
74
            ThriftCommonsSerDeUtils.deserializeTConsensusGroupId(buffer)),
1✔
75
        BasicStructureSerDeUtil.readInt(buffer),
1✔
76
        ThriftCommonsSerDeUtils.deserializeTEndPoint(buffer));
1✔
77
  }
78

79
  @Override
80
  public boolean equals(Object o) {
81
    if (this == o) {
1✔
82
      return true;
×
83
    }
84
    if (o == null || getClass() != o.getClass()) {
1✔
85
      return false;
×
86
    }
87
    Peer peer = (Peer) o;
1✔
88
    return nodeId == peer.nodeId
1✔
89
        && Objects.equals(groupId, peer.groupId)
1✔
90
        && Objects.equals(endpoint, peer.endpoint);
1✔
91
  }
92

93
  @Override
94
  public int hashCode() {
95
    return Objects.hash(groupId, endpoint, nodeId);
1✔
96
  }
97

98
  @Override
99
  public String toString() {
100
    return "Peer{" + "groupId=" + groupId + ", endpoint=" + endpoint + ", nodeId=" + nodeId + '}';
1✔
101
  }
102
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc