NodeInfoSPtr FailoverManagerStoreTest::CreateNodeInfo(int64 low)
    {
        NodeId nodeId(LargeInteger(0, low));
        NodeInstance nodeInstance(nodeId, 0);
        Common::FabricVersionInstance versionInstance;
        std::wstring defaultNodeUpgradeDomainId;
        std::vector<Common::Uri> defaultNodeFaultDomainIds;
        std::map<std::wstring, std::wstring> defaultNodeProperties;
        std::map<std::wstring, uint> defaultCapacityRatios;
        std::map<std::wstring, uint> defaultCapacities;
        std::wstring defaultNodeName;
        std::wstring defaultNodeType;
        std::wstring defaultIpAddressOrFQDN;
        ULONG defaultClientConnectionPort = 0;

        NodeDescription nodeDescription(
            versionInstance,
            defaultNodeUpgradeDomainId,
            defaultNodeFaultDomainIds,
            defaultNodeProperties,
            defaultCapacityRatios,
            defaultCapacities,
            defaultNodeName,
            defaultNodeType,
            defaultIpAddressOrFQDN,
            defaultClientConnectionPort);

        return make_shared<NodeInfo>(nodeInstance, move(nodeDescription), true);
    }
Exemplo n.º 2
0
LargeInteger LargeInteger::add(std::list<int> number)
{
	int sizeOne = listInt.size(); //vecInt - local
	int sizeTwo = number.size();  //number - remote
	//Pad numbers properly
	if(sizeOne > sizeTwo) {
		for(int i = 0; i < sizeOne - sizeTwo; i++)
			number.push_front(0);
	} else if(sizeOne < sizeTwo) {
		for(int i = 0; i < sizeTwo - sizeOne; i++)
			listInt.push_front(0);
	}
	sizeOne = listInt.size();
	sizeTwo = number.size();

	int carry = 0;
	std::list<int> sum;
	std::list<int>::reverse_iterator i = listInt.rbegin();
	std::list<int>::reverse_iterator j = number.rbegin();


	for(i; i != listInt.rend(); i++) {
		std::cout<<"adding "<<*i<<" and "<<*j<<" and carry ("<<carry<<")";
		int n = *i + *j + carry;
		std::cout<<" = "<<n<<std::endl;
		carry = 0;
		if( n >= 10 ) {
			carry = (int)(n/10);
			n = n % 10;
			std::cout<<"\tcarry="<<carry<<" n="<<n<<std::endl;
		}

		sum.push_front(n);
		j++;
	}
	if(carry>0)
		sum.push_front(carry);

	return LargeInteger(sum,false);
}