diff --git a/wedpr-common/utils/src/main/java/com/webank/wedpr/common/config/WeDPRCommonConfig.java b/wedpr-common/utils/src/main/java/com/webank/wedpr/common/config/WeDPRCommonConfig.java index 61a91d8c..d2897293 100644 --- a/wedpr-common/utils/src/main/java/com/webank/wedpr/common/config/WeDPRCommonConfig.java +++ b/wedpr-common/utils/src/main/java/com/webank/wedpr/common/config/WeDPRCommonConfig.java @@ -67,6 +67,7 @@ public class WeDPRCommonConfig { WeDPRConfig.apply("wedpr.worker.api.method.submit", "submit"); private static String SHELL_CODE_CONNECTOR = " && "; + private static String serverListenPort; @SneakyThrows public static String getAgency() { @@ -79,7 +80,7 @@ public static String getAgency() { @SneakyThrows public static String getAdminAgency() { if (StringUtils.isBlank(ADMIN_AGENCY)) { - throw new WeDPRException("Invalid emtpy agency!"); + throw new WeDPRException("Invalid emtpy admin agency!"); } return ADMIN_AGENCY; } @@ -156,4 +157,12 @@ public static String getWedprWorkerApiPath() { public static String getWedprWorkerSubmitTaskMethod() { return WEDPR_WORKER_SUBMIT_TASK_METHOD; } + + public static String getServerListenPort() { + return serverListenPort; + } + + public static void setServerListenPort(String serverListenPort) { + serverListenPort = serverListenPort; + } } diff --git a/wedpr-common/utils/src/main/java/com/webank/wedpr/common/utils/Constant.java b/wedpr-common/utils/src/main/java/com/webank/wedpr/common/utils/Constant.java index 13e04f1c..c41e65f2 100644 --- a/wedpr-common/utils/src/main/java/com/webank/wedpr/common/utils/Constant.java +++ b/wedpr-common/utils/src/main/java/com/webank/wedpr/common/utils/Constant.java @@ -82,4 +82,7 @@ public class Constant { // the pir related fields public static final String PIR_ID_FIELD_NAME = "pir_sys_id"; public static final String PIR_ID_HASH_FIELD_NAME = "pir_sys_id_hash"; + + //// the serviceType + public static final String PIR_SERVICE_TYPE = "PIR"; } diff --git a/wedpr-components/initializer/src/main/java/com/webank/wedpr/components/initializer/WeDPRApplication.java b/wedpr-components/initializer/src/main/java/com/webank/wedpr/components/initializer/WeDPRApplication.java index 711f6509..3b82ebf7 100644 --- a/wedpr-components/initializer/src/main/java/com/webank/wedpr/components/initializer/WeDPRApplication.java +++ b/wedpr-components/initializer/src/main/java/com/webank/wedpr/components/initializer/WeDPRApplication.java @@ -15,6 +15,7 @@ package com.webank.wedpr.components.initializer; +import com.webank.wedpr.common.config.WeDPRCommonConfig; import com.webank.wedpr.common.config.WeDPRConfig; import com.webank.wedpr.common.utils.WeDPRException; import java.io.InputStream; @@ -33,6 +34,7 @@ import org.springframework.context.ApplicationListener; import org.springframework.context.ConfigurableApplicationContext; import org.springframework.context.annotation.ComponentScan; +import org.springframework.core.env.Environment; @SpringBootApplication @ComponentScan(basePackages = {"com.webank"}) @@ -42,6 +44,7 @@ public class WeDPRApplication extends SpringBootServletInitializer { protected static ServiceInfo serviceInfo; protected static ConfigurableApplicationContext applicationContext; + private static String serverListenPort; public static void main(String[] args, String serviceName) throws Exception { final SpringApplication application = new SpringApplication(WeDPRApplication.class); @@ -53,6 +56,11 @@ public void onApplicationEvent(ApplicationPreparedEvent event) { if (applicationContext == null) { applicationContext = event.getApplicationContext(); } + Environment environment = applicationContext.getEnvironment(); + serverListenPort = environment.getProperty("server.port"); + logger.info( + "init WeDPRApplication application, listen port: {}", + serverListenPort); initWeDPRApplication(serviceName); logger.info("init WeDPRApplication application success"); } @@ -82,7 +90,8 @@ protected static void initWeDPRApplication(String serviceName) { } // load config loadConfig(serviceInfo.getConfigFile()); - + // Note: must load WeDPRCommonConfig after config file loaded + WeDPRCommonConfig.setServerListenPort(serverListenPort); logger.info("initWeDPRApplication for {} success", appName); } catch (Exception e) { logger.error("initWeDPRApplication failed, error: ", e); diff --git a/wedpr-components/key-generator/build.gradle b/wedpr-components/key-generator/build.gradle index 90f4b43b..8c053508 100644 --- a/wedpr-components/key-generator/build.gradle +++ b/wedpr-components/key-generator/build.gradle @@ -1,7 +1,5 @@ // Apply the java-library plugin to add support for Java Library plugins { - id 'org.springframework.boot' version '2.3.12.RELEASE' - id 'io.spring.dependency-management' version '1.0.11.RELEASE' id 'java' } diff --git a/wedpr-components/report/src/main/java/com/webank/wedpr/components/report/job/ReportQuartzJob.java b/wedpr-components/report/src/main/java/com/webank/wedpr/components/report/job/ReportQuartzJob.java index 5b26c337..1420f262 100644 --- a/wedpr-components/report/src/main/java/com/webank/wedpr/components/report/job/ReportQuartzJob.java +++ b/wedpr-components/report/src/main/java/com/webank/wedpr/components/report/job/ReportQuartzJob.java @@ -52,7 +52,6 @@ private void doReport() { reportProjectInfo(adminAgency); reportJobInfo(adminAgency); reportJobDatasteRelationInfo(adminAgency); - // reportSysConfig(adminAgency); } catch (Exception e) { log.warn("report error", e); } diff --git a/wedpr-components/task-plugin/pir/src/main/java/com/webank/wedpr/components/task/plugin/pir/service/impl/PirServiceImpl.java b/wedpr-components/task-plugin/pir/src/main/java/com/webank/wedpr/components/task/plugin/pir/service/impl/PirServiceImpl.java index ca5ad356..ba628176 100644 --- a/wedpr-components/task-plugin/pir/src/main/java/com/webank/wedpr/components/task/plugin/pir/service/impl/PirServiceImpl.java +++ b/wedpr-components/task-plugin/pir/src/main/java/com/webank/wedpr/components/task/plugin/pir/service/impl/PirServiceImpl.java @@ -16,10 +16,7 @@ package com.webank.wedpr.components.task.plugin.pir.service.impl; import com.webank.wedpr.common.config.WeDPRCommonConfig; -import com.webank.wedpr.common.utils.Constant; -import com.webank.wedpr.common.utils.ThreadPoolService; -import com.webank.wedpr.common.utils.WeDPRException; -import com.webank.wedpr.common.utils.WeDPRResponse; +import com.webank.wedpr.common.utils.*; import com.webank.wedpr.components.api.credential.core.CredentialVerifier; import com.webank.wedpr.components.api.credential.core.impl.CredentialVerifierImpl; import com.webank.wedpr.components.db.mapper.dataset.mapper.DatasetMapper; @@ -49,6 +46,7 @@ import com.webank.wedpr.components.task.plugin.pir.service.PirService; import com.webank.wedpr.components.task.plugin.pir.transport.PirTopicSubscriber; import com.webank.wedpr.components.task.plugin.pir.transport.impl.PirTopicSubscriberImpl; +import com.webank.wedpr.sdk.jni.transport.TransportConfig; import com.webank.wedpr.sdk.jni.transport.WeDPRTransport; import java.util.List; import javax.annotation.PostConstruct; @@ -105,6 +103,15 @@ public void init() throws Exception { this.pirTopicSubscriber = new PirTopicSubscriberImpl( weDPRTransport, new CredentialVerifierImpl(null), pirServiceHook); + // get the access entrypoint + TransportConfig transportConfig = weDPRTransport.getTransportConfig(); + String accessEntryPoint = + Common.getUrl( + transportConfig.getSelfEndPoint().getHostIP() + + ":" + + WeDPRCommonConfig.getServerListenPort()); + this.weDPRTransport.registerService(Constant.PIR_SERVICE_TYPE, accessEntryPoint); + logger.info("PirServiceImpl, register service, accessEntryPoint: {}", accessEntryPoint); registerPublishedServices(); this.serviceAuthVerifier = new ServiceAuthVerifierImpl(serviceAuthMapper); }