use of org.kin.rsocket.core.metadata.AppMetadata in project kin-rsocket-broker by huangjianqin.
the class DiscoveryServiceImpl method newServiceInstance.
/**
* 构建{@link RSocketServiceInstance}实例
*/
private RSocketServiceInstance newServiceInstance(RSocketEndpoint rsocketEndpoint) {
AppMetadata appMetadata = rsocketEndpoint.getAppMetadata();
RSocketServiceInstance serviceInstance = new RSocketServiceInstance();
serviceInstance.setInstanceId(appMetadata.getUuid());
serviceInstance.setServiceId(appMetadata.getName());
serviceInstance.setHost(appMetadata.getIp());
if (appMetadata.getWebPort() > 0) {
serviceInstance.setPort(appMetadata.getWebPort());
String schema = "http";
serviceInstance.setSecure(appMetadata.isSecure());
// todo 返回https时, http gate抛异常
// if (appMetadata.isSecure()) {
// schema = "https";
// }
serviceInstance.setSchema(schema);
// 返回web port
serviceInstance.setUri(schema + "://" + appMetadata.getIp() + ":" + appMetadata.getWebPort());
}
serviceInstance.setMetadata(appMetadata.getMetadata());
return serviceInstance;
}
use of org.kin.rsocket.core.metadata.AppMetadata in project kin-rsocket-broker by huangjianqin.
the class RSocketServiceManager method updateP2pServiceConsumers.
/**
* 更新指定app应用开启的p2p服务gsv
*/
public void updateP2pServiceConsumers(String appId, Set<String> p2pServiceIds) {
RSocketEndpoint rsocketEndpoint = getByUUID(appId);
if (rsocketEndpoint != null) {
AppMetadata appMetadata = rsocketEndpoint.getAppMetadata();
Integer instanceId = rsocketEndpoint.getId();
appMetadata.updateP2pServiceIds(p2pServiceIds);
Lock writeLock = lock.writeLock();
writeLock.lock();
try {
// copy on write
UnifiedSetMultimap<String, Integer> p2pServiceConsumers = new UnifiedSetMultimap<>(this.p2pServiceConsumers);
for (String p2pService : appMetadata.getP2pServiceIds()) {
p2pServiceConsumers.put(p2pService, instanceId);
rsocketEndpoint.fireCloudEvent(newServiceInstanceChangedCloudEvent(p2pService)).subscribe();
}
this.p2pServiceConsumers = p2pServiceConsumers;
} finally {
writeLock.unlock();
}
}
}
Aggregations