@Test public void addResourceDoesNotHitTheDatabase() { leaderElector.addResource(new ResourceId("test-resource-one")); assertThat(testableLeaderDatabase.databaseHitCount).isEqualTo(0); }
@Override public boolean addResource(ResourceId resourceId) { final boolean addResource = !resourceLeaders.containsKey(resourceId); if (addResource) { resourceLeaders.put(resourceId, LeaderId.UNKNOWN); } return addResource; }
StandardLeaderElector implements LeaderElector, LeaderStatus { @Override public boolean addResource(ResourceId resourceId) { final boolean addResource = !resourceLeaders.containsKey(resourceId); if (addResource) { resourceLeaders.put(resourceId, LeaderId.UNKNOWN); } return addResource; } }
StandardLeaderElector implements LeaderElector, LeaderStatus { @Override public boolean addResource(ResourceId resourceId) { final boolean addResource = !resourceLeaders.containsKey(resourceId); if (addResource) { resourceLeaders.put(resourceId, LeaderId.UNKNOWN); } return addResource; } @Inject  StandardLeaderElector(LeaderDatabase leaderDatabase, Config config, Registry registry);  StandardLeaderElector(
      LeaderId leaderId,
      LeaderDatabase leaderDatabase,
      Config config,
      Registry registry,
      Map<ResourceId, LeaderId> resourceLeaders,
      Id leaderRemovalsCounterId,
      Id resourceLeaderGaugeId,
      Id resourceWithNoLeaderGaugeId
  ); }
StandardLeaderElector implements LeaderElector, LeaderStatus { @Override public boolean addResource(ResourceId resourceId) { final boolean addResource = !resourceLeaders.containsKey(resourceId); if (addResource) { resourceLeaders.put(resourceId, LeaderId.UNKNOWN); } return addResource; } @Inject  StandardLeaderElector(LeaderDatabase leaderDatabase, Config config, Registry registry);  StandardLeaderElector(
      LeaderId leaderId,
      LeaderDatabase leaderDatabase,
      Config config,
      Registry registry,
      Map<ResourceId, LeaderId> resourceLeaders,
      Id leaderRemovalsCounterId,
      Id resourceLeaderGaugeId,
      Id resourceWithNoLeaderGaugeId
  ); @Override boolean addResource(ResourceId resourceId); @Override LeaderId getLeaderFor(ResourceId resourceId); @Override Set<ResourceId> getResources(); @Override void initialize(); @Override boolean removeLeaderFor(ResourceId resourceId); @Override boolean removeResource(ResourceId resourceId); @Override void runElection(); @Override boolean hasLeadership(); @Override boolean hasLeadershipFor(ResourceId resourceId); }
StandardLeaderElector implements LeaderElector, LeaderStatus { @Override public boolean addResource(ResourceId resourceId) { final boolean addResource = !resourceLeaders.containsKey(resourceId); if (addResource) { resourceLeaders.put(resourceId, LeaderId.UNKNOWN); } return addResource; } @Inject  StandardLeaderElector(LeaderDatabase leaderDatabase, Config config, Registry registry);  StandardLeaderElector(
      LeaderId leaderId,
      LeaderDatabase leaderDatabase,
      Config config,
      Registry registry,
      Map<ResourceId, LeaderId> resourceLeaders,
      Id leaderRemovalsCounterId,
      Id resourceLeaderGaugeId,
      Id resourceWithNoLeaderGaugeId
  ); @Override boolean addResource(ResourceId resourceId); @Override LeaderId getLeaderFor(ResourceId resourceId); @Override Set<ResourceId> getResources(); @Override void initialize(); @Override boolean removeLeaderFor(ResourceId resourceId); @Override boolean removeResource(ResourceId resourceId); @Override void runElection(); @Override boolean hasLeadership(); @Override boolean hasLeadershipFor(ResourceId resourceId);  }