Search in sources :

Example 1 with ClientAttributes

use of com.alibaba.nacos.naming.core.v2.client.ClientAttributes in project nacos by alibaba.

the class ConnectionBasedClientManager method clientConnected.

@Override
public void clientConnected(Connection connect) {
    if (!RemoteConstants.LABEL_MODULE_NAMING.equals(connect.getMetaInfo().getLabel(RemoteConstants.LABEL_MODULE))) {
        return;
    }
    ClientAttributes attributes = new ClientAttributes();
    attributes.addClientAttribute(ClientConstants.CONNECTION_TYPE, connect.getMetaInfo().getConnectType());
    attributes.addClientAttribute(ClientConstants.CONNECTION_METADATA, connect.getMetaInfo());
    clientConnected(connect.getMetaInfo().getConnectionId(), attributes);
}
Also used : ClientAttributes(com.alibaba.nacos.naming.core.v2.client.ClientAttributes)

Example 2 with ClientAttributes

use of com.alibaba.nacos.naming.core.v2.client.ClientAttributes in project nacos by alibaba.

the class ConnectionBasedClientManager method clientConnected.

@Override
public boolean clientConnected(String clientId, ClientAttributes attributes) {
    String type = attributes.getClientAttribute(ClientConstants.CONNECTION_TYPE);
    ClientFactory clientFactory = ClientFactoryHolder.getInstance().findClientFactory(type);
    return clientConnected(clientFactory.newClient(clientId, attributes));
}
Also used : ClientFactory(com.alibaba.nacos.naming.core.v2.client.factory.ClientFactory)

Example 3 with ClientAttributes

use of com.alibaba.nacos.naming.core.v2.client.ClientAttributes in project nacos by alibaba.

the class ConnectionBasedClientManager method syncClientConnected.

@Override
public boolean syncClientConnected(String clientId, ClientAttributes attributes) {
    String type = attributes.getClientAttribute(ClientConstants.CONNECTION_TYPE);
    ClientFactory clientFactory = ClientFactoryHolder.getInstance().findClientFactory(type);
    return clientConnected(clientFactory.newSyncedClient(clientId, attributes));
}
Also used : ClientFactory(com.alibaba.nacos.naming.core.v2.client.factory.ClientFactory)

Example 4 with ClientAttributes

use of com.alibaba.nacos.naming.core.v2.client.ClientAttributes in project nacos by alibaba.

the class PersistentClientOperationServiceImpl method onInstanceRegister.

private void onInstanceRegister(Service service, Instance instance, String clientId) {
    Service singleton = ServiceManager.getInstance().getSingleton(service);
    if (!clientManager.contains(clientId)) {
        clientManager.clientConnected(clientId, new ClientAttributes());
    }
    Client client = clientManager.getClient(clientId);
    InstancePublishInfo instancePublishInfo = getPublishInfo(instance);
    client.addServiceInstance(singleton, instancePublishInfo);
    client.setLastUpdatedTime();
    NotifyCenter.publishEvent(new ClientOperationEvent.ClientRegisterServiceEvent(singleton, clientId));
}
Also used : ClientOperationEvent(com.alibaba.nacos.naming.core.v2.event.client.ClientOperationEvent) InstancePublishInfo(com.alibaba.nacos.naming.core.v2.pojo.InstancePublishInfo) ClientOperationService(com.alibaba.nacos.naming.core.v2.service.ClientOperationService) Service(com.alibaba.nacos.naming.core.v2.pojo.Service) IpPortBasedClient(com.alibaba.nacos.naming.core.v2.client.impl.IpPortBasedClient) Client(com.alibaba.nacos.naming.core.v2.client.Client) ClientAttributes(com.alibaba.nacos.naming.core.v2.client.ClientAttributes)

Aggregations

ClientAttributes (com.alibaba.nacos.naming.core.v2.client.ClientAttributes)2 ClientFactory (com.alibaba.nacos.naming.core.v2.client.factory.ClientFactory)2 Client (com.alibaba.nacos.naming.core.v2.client.Client)1 IpPortBasedClient (com.alibaba.nacos.naming.core.v2.client.impl.IpPortBasedClient)1 ClientOperationEvent (com.alibaba.nacos.naming.core.v2.event.client.ClientOperationEvent)1 InstancePublishInfo (com.alibaba.nacos.naming.core.v2.pojo.InstancePublishInfo)1 Service (com.alibaba.nacos.naming.core.v2.pojo.Service)1 ClientOperationService (com.alibaba.nacos.naming.core.v2.service.ClientOperationService)1