use of org.apache.geode.internal.cache.BucketAdvisor.BucketProfile in project geode by apache.
the class AcceptorImpl method start.
@Override
public void start() throws IOException {
ThreadGroup tg = LoggingThreadGroup.createThreadGroup("Acceptor " + this.serverSock.getInetAddress() + ":" + this.localPort, logger);
thread = new Thread(tg, this, "Cache Server Acceptor " + this.serverSock.getInetAddress() + ":" + this.localPort + " local port: " + this.serverSock.getLocalPort());
this.acceptorId = thread.getId();
// This thread should not be a daemon to keep BridgeServers created
// in code from exiting immediately.
thread.start();
if (isSelector()) {
Runnable r = new Runnable() {
public void run() {
AcceptorImpl.this.runSelectorLoop();
}
};
this.selectorThread = new Thread(tg, r, "Cache Server Selector " + this.serverSock.getInetAddress() + ":" + this.localPort + " local port: " + this.serverSock.getLocalPort());
this.selectorThread.start();
}
Set<PartitionedRegion> prs = this.cache.getPartitionedRegions();
for (PartitionedRegion pr : prs) {
Map<Integer, BucketAdvisor.BucketProfile> profiles = new HashMap<Integer, BucketAdvisor.BucketProfile>();
// get all local real bucket advisors
Map<Integer, BucketAdvisor> advisors = pr.getRegionAdvisor().getAllBucketAdvisors();
for (Map.Entry<Integer, BucketAdvisor> entry : advisors.entrySet()) {
BucketAdvisor advisor = entry.getValue();
// addLocally
BucketProfile bp = (BucketProfile) advisor.createProfile();
advisor.updateServerBucketProfile(bp);
// advisor.basicAddClientProfile(bp);
profiles.put(entry.getKey(), bp);
}
Set receipients = new HashSet();
receipients = pr.getRegionAdvisor().adviseAllPRNodes();
// send it to all in one messgae
ReplyProcessor21 reply = AllBucketProfilesUpdateMessage.send(receipients, pr.getDistributionManager(), pr.getPRId(), profiles, true);
if (reply != null) {
reply.waitForRepliesUninterruptibly();
}
}
}
use of org.apache.geode.internal.cache.BucketAdvisor.BucketProfile in project geode by apache.
the class RegionAdvisor method getAllClientBucketProfiles.
/**
* Returns an unmodifiable map of bucket IDs to locations hosting the bucket.
*/
public Map<Integer, List<BucketServerLocation66>> getAllClientBucketProfiles() {
Map<Integer, List<BucketServerLocation66>> bucketToServerLocations = new HashMap<Integer, List<BucketServerLocation66>>();
for (Integer bucketId : this.clientBucketProfilesMap.keySet()) {
ArrayList<BucketServerLocation66> clientBucketProfiles = new ArrayList<BucketServerLocation66>();
for (BucketProfile profile : this.clientBucketProfilesMap.get(bucketId)) {
if (profile.isHosting) {
ServerBucketProfile cProfile = (ServerBucketProfile) profile;
Set<BucketServerLocation66> bucketServerLocations = cProfile.getBucketServerLocations();
// Either we can make BucketServeLocation having ServerLocation with them
// Or we can create bucketServerLocation as it is by iterating over the set of servers
clientBucketProfiles.addAll(bucketServerLocations);
}
}
bucketToServerLocations.put(bucketId, clientBucketProfiles);
}
if (getPartitionedRegion().isDataStore()) {
for (Integer bucketId : getPartitionedRegion().getDataStore().getAllLocalBucketIds()) {
BucketProfile profile = getBucketAdvisor(bucketId).getLocalProfile();
if (logger.isDebugEnabled()) {
logger.debug("The local profile is : {}", profile);
}
if (profile != null) {
List<BucketServerLocation66> clientBucketProfiles = bucketToServerLocations.get(bucketId);
if (clientBucketProfiles == null) {
clientBucketProfiles = new ArrayList<BucketServerLocation66>();
bucketToServerLocations.put(bucketId, clientBucketProfiles);
}
if ((profile instanceof ServerBucketProfile) && profile.isHosting) {
ServerBucketProfile cProfile = (ServerBucketProfile) profile;
Set<BucketServerLocation66> bucketServerLocations = cProfile.getBucketServerLocations();
// Either we can make BucketServeLocation having ServerLocation with
// them
// Or we can create bucketServerLocation as it is by iterating over
// the set of servers
clientBucketProfiles.removeAll(bucketServerLocations);
clientBucketProfiles.addAll(bucketServerLocations);
}
}
}
}
return bucketToServerLocations;
}
use of org.apache.geode.internal.cache.BucketAdvisor.BucketProfile in project geode by apache.
the class RegionAdvisor method getAllClientBucketProfilesTest.
public ConcurrentHashMap<Integer, Set<ServerBucketProfile>> getAllClientBucketProfilesTest() {
ConcurrentHashMap<Integer, Set<ServerBucketProfile>> map = new ConcurrentHashMap<Integer, Set<ServerBucketProfile>>();
Map<Integer, List<BucketServerLocation66>> testMap = new HashMap<>(this.getAllClientBucketProfiles());
for (Integer bucketId : testMap.keySet()) {
Set<ServerBucketProfile> parr = new HashSet<>(this.clientBucketProfilesMap.get(bucketId));
map.put(bucketId, parr);
}
if (getPartitionedRegion().isDataStore()) {
for (Integer bucketId : getPartitionedRegion().getDataStore().getAllLocalBucketIds()) {
BucketProfile profile = getBucketAdvisor(bucketId).getLocalProfile();
if ((profile instanceof ServerBucketProfile) && profile.isHosting) {
map.get(bucketId).add((ServerBucketProfile) profile);
}
}
}
if (logger.isDebugEnabled()) {
logger.debug("This maps is sksk {} and size is {}", map, map.keySet().size());
}
return map;
}
use of org.apache.geode.internal.cache.BucketAdvisor.BucketProfile in project geode by apache.
the class BucketRegion method fillInProfile.
@Override
public void fillInProfile(Profile profile) {
super.fillInProfile(profile);
BucketProfile bp = (BucketProfile) profile;
bp.isInitializing = this.initializationLatchAfterGetInitialImage.getCount() > 0;
}
use of org.apache.geode.internal.cache.BucketAdvisor.BucketProfile in project geode by apache.
the class AcceptorImpl method notifyCacheMembersOfClose.
private void notifyCacheMembersOfClose() {
if (!this.cache.forcedDisconnect()) {
for (PartitionedRegion pr : this.cache.getPartitionedRegions()) {
Map<Integer, BucketAdvisor.BucketProfile> profiles = new HashMap<>();
// get all local real bucket advisors
Map<Integer, BucketAdvisor> advisors = pr.getRegionAdvisor().getAllBucketAdvisors();
for (Map.Entry<Integer, BucketAdvisor> entry : advisors.entrySet()) {
BucketAdvisor advisor = entry.getValue();
BucketProfile bp = (BucketProfile) advisor.createProfile();
advisor.updateServerBucketProfile(bp);
profiles.put(entry.getKey(), bp);
}
Set recipients = pr.getRegionAdvisor().adviseAllPRNodes();
// send it to all in one message
ReplyProcessor21 reply = AllBucketProfilesUpdateMessage.send(recipients, pr.getDistributionManager(), pr.getPRId(), profiles, true);
if (reply != null) {
reply.waitForRepliesUninterruptibly();
}
if (logger.isDebugEnabled()) {
logger.debug("sending messages to all peers for removing this server..");
}
}
}
}
Aggregations