private Map<String, List<Node>> getEggTargetToNodes() { Map<String, List<Node>> result = Maps.newConcurrentMap(); Node healthyEggNode = new Node(); healthyEggNode.setType(NodeType.EGG.name()); healthyEggNode.setStatus(NodeStatus.HEALTHY.name()); List<Node> healthyEggs = storageMetaClient.getNodes(healthyEggNode); for (Node node : healthyEggs) { String target = networkingUtils.getIpOrHost(node); if (!result.containsKey(target)) { result.put(target, Lists.newArrayList()); } List<Node> targetList = result.get(target); targetList.add(node); } return result; }
public synchronized BasicMeta.Endpoint getRollEndpoint() { if (rollEndpoint == null) { init(); try { Node node = new Node(); node.setType(NodeType.ROLL.name()); node.setStatus(NodeStatus.HEALTHY.name()); List<Node> nodes = storageMetaClient.getNodes(node); if (nodes == null || nodes.isEmpty()) { throw new IllegalStateException("no valid roll node exists"); } rollEndpoint = typeConversionUtils.toEndpoint(nodes.get(0)); } catch (Exception e) { LOGGER.info("[ROLL][INIT] init roll endpoint failed. using default"); rollEndpoint = RuntimeConstants.getLocalEndpoint(8011); } } return rollEndpoint; } }
public synchronized void loadProxy() { LOGGER.info("[FEDERATION][PROXY][SELECTION] loading"); storageMetaClient.init(federationServerUtils.getMetaServiceEndpoint()); proxies.clear(); Node node = new Node(); node.setType(NodeType.PROXY.name()); node.setStatus(NodeStatus.HEALTHY.name()); List<Node> nodes = storageMetaClient.getNodes(node); BasicMeta.Endpoint endpoint = null; for (Node cur : nodes) { endpoint = typeConversionUtils.toEndpoint(cur); proxies.add(endpoint); } }
@Override public List<Node> process(Object record) throws CrudException { GenericDaoService genericDaoService = nodeGrpcCrudService.getGenericDaoService(); List<Node> result = null; NodeStatus nodeStatus = (NodeStatus) record; NodeExample example = new NodeExample(); example.createCriteria().andStatusEqualTo(nodeStatus.name()); Object callResult = genericDaoService.selectByExample(example); result = (List<Node>) callResult; return result; }
@Override public List<Node> process(Object record) throws CrudException { GenericDaoService nodeDaoService = nodeGrpcCrudService.getGenericDaoService(); GenericDaoService fragmentDaoService = fragmentGrpcCrudService.getGenericDaoService(); Long tableId = (Long) record; FragmentExample fragmentExample = new FragmentExample(); fragmentExample.createCriteria().andTableIdEqualTo(tableId); List<Fragment> fragments = fragmentDaoService.selectByExample(fragmentExample); List<Long> nodeIds = Lists.newArrayList(); for (Fragment fragment : fragments) { nodeIds.add(fragment.getNodeId()); } NodeExample nodeExample = new NodeExample(); nodeExample.createCriteria() .andNodeIdIn(nodeIds) .andStatusEqualTo(NodeStatus.HEALTHY.name()); List<Node> result = nodeDaoService.selectByExample(nodeExample); return result; }
nodeExample.createCriteria().andStatusEqualTo(NodeStatus.HEALTHY.name()) .andTypeEqualTo(NodeType.STORAGE.name()); List<Node> healthyStorageNodes = nodeDaoService.selectByExample(nodeExample);