@Override
    public void register(ProviderConfig config) {
        String appName = config.getAppName();

        if (!registryConfig.isRegister()) {
            if (LOGGER.isInfoEnabled(appName)) {
                LOGGER.infoWithApp(appName, LogCodes.getLog(LogCodes.INFO_REGISTRY_IGNORE));
            }
            return;
        }
        if (!config.isRegister()) {
            return;
        }

        try {
            List<InstanceRegisterRequest> services = buildPolarisRegister(config);
            if (CommonUtils.isNotEmpty(services)) {
                if (LOGGER.isInfoEnabled(appName)) {
                    LOGGER.infoWithApp(appName, LogCodes.getLog(LogCodes.INFO_ROUTE_REGISTRY_PUB_START, config.getInterfaceId()));
                }
                for (InstanceRegisterRequest service : services) {
                    registerPolarisService(config, service);
                    if (LOGGER.isInfoEnabled(appName)) {
                        LOGGER.infoWithApp(appName, LogCodes.getLog(LogCodes.INFO_ROUTE_REGISTRY_PUB, config.getInterfaceId()));
                    }
                }
                if (LOGGER.isInfoEnabled(appName)) {
                    LOGGER.infoWithApp(appName, LogCodes.getLog(LogCodes.INFO_ROUTE_REGISTRY_PUB_OVER, config.getInterfaceId()));
                }
            }
        } catch (SofaRpcRuntimeException e) {
            throw e;
        } catch (Exception e) {
            throw new SofaRpcRuntimeException(LogCodes.getLog(LogCodes.ERROR_REG_PROVIDER, "polarisRegistry", config.buildKey()), e);
        }
        if (EventBus.isEnable(ProviderPubEvent.class)) {
            ProviderPubEvent event = new ProviderPubEvent(config);
            EventBus.post(event);
        }

    }
@Test
    public void testRegister() {
        polaris.getNamingService().addService(new ServiceKey(NAMESPACE, SERVICE));
        //register
        ProviderConfig<?> providerConfig = providerConfig("polaris-test-1", 12200, 12201, 12202);
        registry.register(providerConfig);
        //check register
        ConsumerAPI consumerAPI = DiscoveryAPIFactory.createConsumerAPI();
        GetAllInstancesRequest getAllInstancesRequest = new GetAllInstancesRequest();
        getAllInstancesRequest.setNamespace(APPNAME);
        getAllInstancesRequest.setService(SERVICE);
        InstancesResponse allInstance = consumerAPI.getAllInstance(getAllInstancesRequest);
        Assert.assertEquals(3, allInstance.getInstances().length);

        //unregister
        registry.unRegister(providerConfig);

        //check unregister ,sleep to wait remove catch
        try {
            Thread.sleep(5000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        //if no service will throw a exception
        try {
            consumerAPI.getAllInstance(getAllInstancesRequest);
        } catch (PolarisException e) {
            Assert.assertEquals(SERVER_USER_ERROR, e.getCode());
        }
    }