1 package org.apache.helix.controller.stages;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import java.util.Map;
23
24 import org.apache.helix.HelixManager;
25 import org.apache.helix.HelixManagerProperties;
26 import org.apache.helix.controller.pipeline.AbstractBaseStage;
27 import org.apache.helix.controller.pipeline.StageException;
28 import org.apache.helix.model.LiveInstance;
29 import org.apache.log4j.Logger;
30
31
32
33
34
35 public class CompatibilityCheckStage extends AbstractBaseStage {
36 private static final Logger LOG = Logger
37 .getLogger(CompatibilityCheckStage.class.getName());
38
39 @Override
40 public void process(ClusterEvent event) throws Exception
41 {
42 HelixManager manager = event.getAttribute("helixmanager");
43 ClusterDataCache cache = event.getAttribute("ClusterDataCache");
44 if (manager == null || cache == null)
45 {
46 throw new StageException("Missing attributes in event:" + event
47 + ". Requires HelixManager | DataCache");
48 }
49
50 HelixManagerProperties properties = manager.getProperties();
51 Map<String, LiveInstance> liveInstanceMap = cache.getLiveInstances();
52 for (LiveInstance liveInstance : liveInstanceMap.values())
53 {
54 String participantVersion = liveInstance.getHelixVersion();
55 if (!properties.isParticipantCompatible(participantVersion))
56 {
57 String errorMsg = "incompatible participant. pipeline will not continue. "
58 + "controller: " + manager.getInstanceName()
59 + ", controllerVersion: " + properties.getVersion()
60 + ", minimumSupportedParticipantVersion: "
61 + properties.getProperty("miminum_supported_version.participant")
62 + ", participant: " + liveInstance.getInstanceName()
63 + ", participantVersion: " + participantVersion;
64 LOG.error(errorMsg);
65 throw new StageException(errorMsg);
66 }
67 }
68 }
69 }