EndpointInfo.cpp 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /**
  2. * Tencent is pleased to support the open source community by making Tars available.
  3. *
  4. * Copyright (C) 2016THL A29 Limited, a Tencent company. All rights reserved.
  5. *
  6. * Licensed under the BSD 3-Clause License (the "License"); you may not use this file except
  7. * in compliance with the License. You may obtain a copy of the License at
  8. *
  9. * https://opensource.org/licenses/BSD-3-Clause
  10. *
  11. * Unless required by applicable law or agreed to in writing, software distributed
  12. * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
  13. * CONDITIONS OF ANY KIND, either express or implied. See the License for the
  14. * specific language governing permissions and limitations under the License.
  15. */
  16. #include "servant/EndpointInfo.h"
  17. #include "servant/RemoteLogger.h"
  18. //#include "servant/NetworkUtil.h"
  19. #include "util/tc_socket.h"
  20. namespace tars
  21. {
  22. EndpointInfo::EndpointInfo()
  23. {
  24. _setDivision.clear();
  25. // memset(&_addr,0,sizeof(_addr));
  26. }
  27. EndpointInfo::EndpointInfo(const TC_Endpoint &ep, const string &setDivision)
  28. : _ep(ep)
  29. , _setDivision(setDivision)
  30. // , _addressSucc(false)
  31. {
  32. _cmpDesc = createCompareDesc();
  33. _desc = createDesc();
  34. }
  35. EndpointInfo::EndpointInfo(const EndpointF &ep)
  36. : _setDivision(ep.setId)
  37. {
  38. _ep.setHost(ep.host);
  39. _ep.setPort(ep.port);
  40. _ep.setTimeout(ep.timeout);
  41. _ep.setType((TC_Endpoint::EType)ep.istcp);
  42. _ep.setGrid(ep.grid);
  43. _ep.setQos(ep.qos);
  44. _ep.setWeight(ep.weight);
  45. _ep.setWeightType(ep.weightType);
  46. _ep.setAuthType((TC_Endpoint::AUTH_TYPE)ep.authType);
  47. _cmpDesc = createCompareDesc();
  48. _desc = createDesc();
  49. }
  50. string EndpointInfo::createCompareDesc()
  51. {
  52. stringstream ss;
  53. ss << _ep.getType() << ":" << _ep.getHost() << ":" << _ep.getPort();
  54. return ss.str();
  55. }
  56. ///////////////////////////////////////////////////////////
  57. }