@Override public MasterCoprocessor checkAndGetInstance(Class<?> implClass) throws InstantiationException, IllegalAccessException { if (MasterCoprocessor.class.isAssignableFrom(implClass)) { return (MasterCoprocessor)implClass.newInstance(); } else if (CoprocessorService.class.isAssignableFrom(implClass)) { // For backward compatibility with old CoprocessorService impl which don't extend // MasterCoprocessor. return new CoprocessorServiceBackwardCompatiblity.MasterCoprocessorService( (CoprocessorService)implClass.newInstance()); } else { LOG.error(implClass.getName() + " is not of type MasterCoprocessor. Check the " + "configuration " + CoprocessorHost.MASTER_COPROCESSOR_CONF_KEY); return null; } }
@Override public RegionCoprocessor checkAndGetInstance(Class<?> implClass) throws InstantiationException, IllegalAccessException { if (RegionCoprocessor.class.isAssignableFrom(implClass)) { return (RegionCoprocessor)implClass.newInstance(); } else if (CoprocessorService.class.isAssignableFrom(implClass)) { // For backward compatibility with old CoprocessorService impl which don't extend // RegionCoprocessor. return new CoprocessorServiceBackwardCompatiblity.RegionCoprocessorService( (CoprocessorService)implClass.newInstance()); } else { LOG.error(implClass.getName() + " is not of type RegionCoprocessor. Check the " + "configuration " + CoprocessorHost.REGION_COPROCESSOR_CONF_KEY); return null; } }
@Override public RegionEnvironment createEnvironment(Class<?> implClass, Coprocessor instance, int priority, int seq, Configuration conf) { // Check if it's an Endpoint. // Due to current dynamic protocol design, Endpoint // uses a different way to be registered and executed. // It uses a visitor pattern to invoke registered Endpoint // method. for (Object itf : ClassUtils.getAllInterfaces(implClass)) { Class<?> c = (Class<?>) itf; if (CoprocessorService.class.isAssignableFrom(c)) { region.registerService( ((CoprocessorService)instance).getService() ); } } ConcurrentMap<String, Object> classData; // make sure only one thread can add maps synchronized (sharedDataMap) { // as long as at least one RegionEnvironment holds on to its classData it will // remain in this map classData = (ConcurrentMap<String, Object>)sharedDataMap.get(implClass.getName()); if (classData == null) { classData = new ConcurrentHashMap<String, Object>(); sharedDataMap.put(implClass.getName(), classData); } } return new RegionEnvironment(instance, priority, seq, conf, region, rsServices, classData); }
@Override public RegionEnvironment createEnvironment(Class<?> implClass, Coprocessor instance, int priority, int seq, Configuration conf) { // Check if it's an Endpoint. // Due to current dynamic protocol design, Endpoint // uses a different way to be registered and executed. // It uses a visitor pattern to invoke registered Endpoint // method. for (Class<?> c : implClass.getInterfaces()) { if (CoprocessorService.class.isAssignableFrom(c)) { region.registerService( ((CoprocessorService)instance).getService() ); } } ConcurrentMap<String, Object> classData; // make sure only one thread can add maps synchronized (sharedDataMap) { // as long as at least one RegionEnvironment holds on to its classData it will // remain in this map classData = (ConcurrentMap<String, Object>)sharedDataMap.get(implClass.getName()); if (classData == null) { classData = new ConcurrentHashMap<String, Object>(); sharedDataMap.put(implClass.getName(), classData); } } return new RegionEnvironment(instance, priority, seq, conf, region, rsServices, classData); }
@Override public RegionEnvironment createEnvironment(Class<?> implClass, Coprocessor instance, int priority, int seq, Configuration conf) { // Check if it's an Endpoint. // Due to current dynamic protocol design, Endpoint // uses a different way to be registered and executed. // It uses a visitor pattern to invoke registered Endpoint // method. for (Class c : implClass.getInterfaces()) { if (CoprocessorService.class.isAssignableFrom(c)) { region.registerService( ((CoprocessorService)instance).getService() ); } } ConcurrentMap<String, Object> classData; // make sure only one thread can add maps synchronized (sharedDataMap) { // as long as at least one RegionEnvironment holds on to its classData it will // remain in this map classData = (ConcurrentMap<String, Object>)sharedDataMap.get(implClass.getName()); if (classData == null) { classData = new ConcurrentHashMap<String, Object>(); sharedDataMap.put(implClass.getName(), classData); } } return new RegionEnvironment(instance, priority, seq, conf, region, rsServices, classData); }