Examples of Replica


Examples of org.apache.hadoop.hdfs.server.datanode.Replica

    List<LocatedBlock> lb = cluster.getNameNode().getBlockLocations(
      filePath.toString(), FILE_SIZE - 1, FILE_SIZE).getLocatedBlocks();

    for (DataNode dn : cluster.getDataNodes()) {
      Replica r = DataNodeAdapter.fetchReplicaInfo(
        dn, lb.get(0).getBlock().getBlockId());

      assertTrue("Replica on DN " + dn + " shouldn't be null", r != null);
      assertEquals(
        "Should be RBW replica on " + dn + " after sequence of calls " +
        "append()/write()/hflush()",
        HdfsConstants.ReplicaState.RBW, r.getState());
    }
    ofs.close();
  }
View Full Code Here

Examples of org.apache.hadoop.hdfs.server.datanode.Replica

    return volumeMap.get(bpid, blockId);
  }

  @Override
  public synchronized String getReplicaString(String bpid, long blockId) {
    final Replica r = volumeMap.get(bpid, blockId);
    return r == null? "null": r.toString();
  }
View Full Code Here

Examples of org.apache.hadoop.hdfs.server.datanode.Replica

  }

  @Override // FsDatasetSpi
  public synchronized long getReplicaVisibleLength(final ExtendedBlock block)
  throws IOException {
    final Replica replica = getReplicaInfo(block.getBlockPoolId(),
        block.getBlockId());
    if (replica.getGenerationStamp() < block.getGenerationStamp()) {
      throw new IOException(
          "replica.getGenerationStamp() < block.getGenerationStamp(), block="
          + block + ", replica=" + replica);
    }
    return replica.getVisibleLength();
  }
View Full Code Here

Examples of org.apache.hadoop.hdfs.server.datanode.Replica

    List<LocatedBlock> lb = cluster.getNameNodeRpc().getBlockLocations(
      filePath.toString(), FILE_SIZE - 1, FILE_SIZE).getLocatedBlocks();

    String bpid = cluster.getNamesystem().getBlockPoolId();
    for (DataNode dn : cluster.getDataNodes()) {
      Replica r = DataNodeTestUtils.fetchReplicaInfo(dn, bpid, lb.get(0)
          .getBlock().getBlockId());

      assertTrue("Replica on DN " + dn + " shouldn't be null", r != null);
      assertEquals("Should be RBW replica on " + dn
          + " after sequence of calls append()/write()/hflush()",
          HdfsServerConstants.ReplicaState.RBW, r.getState());
    }
    ofs.close();
  }
View Full Code Here

Examples of org.apache.hadoop.hdfs.server.datanode.Replica

    List<LocatedBlock> lb = cluster.getNameNodeRpc().getBlockLocations(
      filePath.toString(), FILE_SIZE - 1, FILE_SIZE).getLocatedBlocks();

    String bpid = cluster.getNamesystem().getBlockPoolId();
    for (DataNode dn : cluster.getDataNodes()) {
      Replica r = DataNodeTestUtils.fetchReplicaInfo(dn, bpid, lb.get(0)
          .getBlock().getBlockId());

      assertTrue("Replica on DN " + dn + " shouldn't be null", r != null);
      assertEquals("Should be RBW replica on " + dn
          + " after sequence of calls append()/write()/hflush()",
          HdfsServerConstants.ReplicaState.RBW, r.getState());
    }
    ofs.close();
  }
View Full Code Here

Examples of org.robotninjas.barge.Replica

          Term term = entry.getTerm();
          visitor.term(mark, term.getTerm());
        } else if (entry.hasVote()) {
          Vote vote = entry.getVote();
          String votedfor = vote.getVotedFor();
          Replica replica = votedfor == null
            ? null : config.getReplica(votedfor);
          visitor.vote(mark, Optional.fromNullable(replica));
        }

      }
View Full Code Here

Examples of org.robotninjas.barge.Replica

    //  If votedFor is null or candidateId, and candidate's log is at
    //  least as up-to-date as receiver’s log, grant vote (§5.2, §5.4)
     
    Optional<Replica> votedFor = log.votedFor();
    Replica candidate = log.getReplica(request.getCandidateId());

    if (votedFor.isPresent()) {
      if (!votedFor.get().equals(candidate)) {
        return false;
      }
View Full Code Here

Examples of org.robotninjas.barge.Replica

          ctx.setState(this, FOLLOWER);
        }

      }

      Replica candidate = log.getReplica(request.getCandidateId());
      voteGranted = shouldVoteFor(log, request);

      if (voteGranted) {
        log.votedFor(Optional.of(candidate));
      }
View Full Code Here

Examples of org.robotninjas.barge.Replica

      .setLastLogIndex(2)
      .setLastLogTerm(3)
      .setTerm(2)
      .build();

    Replica otherCandidate = config.getReplica("other");
    when(mockRaftLog.votedFor()).thenReturn(Optional.of(otherCandidate));
    boolean shouldVote = state.shouldVoteFor(mockRaftLog, requestVote);

    assertTrue(shouldVote);
  }
View Full Code Here

Examples of org.robotninjas.barge.Replica

      .setLastLogIndex(2)
      .setLastLogTerm(1)
      .setTerm(2)
      .build();

    Replica otherCandidate = config.getReplica("other");
    when(mockRaftLog.votedFor()).thenReturn(Optional.of(otherCandidate));
    boolean shouldVote = state.shouldVoteFor(mockRaftLog, requestVote);

    assertFalse(shouldVote);
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.