// OVS-2204: there were errors even on retry with a new connection which actually
// should have succeeded - try to get to the bottom of that
TEST_F(BackendInterfaceTest, retry_on_error)
{
    const std::string oname("some-object");
    const fs::path opath(path_ / oname);

    const yt::CheckSum cs(createTestFile(opath,
                                         4096,
                                         "some pattern"));

    yt::CheckSum wrong_cs(1);

    ASSERT_NE(wrong_cs,
              cs);

    std::unique_ptr<be::BackendTestSetup::WithRandomNamespace>
        nspace(make_random_namespace());

    const size_t retries = 7;
    ASSERT_LE(retries,
              cm_->capacity());

    be::BackendInterfacePtr bi(cm_->newBackendInterface(nspace->ns(),
                                                        retries));

    ASSERT_THROW(bi->write(opath,
                           oname,
                           OverwriteObject::F,
                           &wrong_cs),
                 be::BackendInputException);

    ASSERT_EQ(retries + 1,
              cm_->size());
}
// OVS-2204: for some reason the count of open fds goes up after an error, but
//  valgrind does not report a leak. Try to figure our what's going on here.
TEST_F(ConnectionManagerTest, limited_pool_on_errors)
{
    std::async(std::launch::async,
               [&]
               {
                   pin_to_cpu_0();
                   const std::string oname("some-object");
                   const fs::path opath(path_ / oname);

                   const yt::CheckSum cs(createTestFile(opath,
                                                        4096,
                                                        "some pattern"));

                   yt::CheckSum wrong_cs(1);

                   ASSERT_NE(wrong_cs,
                             cs);

                   std::unique_ptr<be::BackendTestSetup::WithRandomNamespace>
                       nspace(make_random_namespace());

                   be::BackendInterfacePtr bi(bi_(nspace->ns()));
                   const size_t count = 2 * cm_->capacity();

                   for (size_t i = 0; i < count; ++i)
                   {
                       ASSERT_THROW(bi->write(opath,
                                              oname,
                                              OverwriteObject::F,
                                              &wrong_cs),
                                    be::BackendInputException);
                   }

                   ASSERT_EQ(cm_->capacity() / cm_->shards(),
                             cm_->size());
               }).wait();
}
Esempio n. 3
0
void plexser::tokenize()
{
	dbg::trace tr("plexser", DBG_HERE);
	char current;

	input->seekg(0);
	lineNum = 1;
	columnNum = 1;
	current = getChar();
	while(!input->eof())
	{
		//std::cout << "HERE" << std::endl;
		//std::cout << current << std::endl;

		if(isspace(current))
		{
			eatWhiteSpace();
		}
		else if(current == '/' && (input->peek() == '/' || input->peek() == '*'))
		{
			eatComments();
		}
		else
			if(state == plexser::skiptogen)
			{
				NonGenerated(current);
			}
			else if(state == plexser::funcheader)
			{

				input->unget();
				std::streampos pos = input->tellg();
				input->get();

				std::pair<std::string, char> current_token = nextToken(current);
				current = getChar();
				if(current_token.first == "using")
				{
					// create namespace and class object
					std::string ns_and_class = nextToken(current).first;
				std::string::size_type pos = ns_and_class.find("::", 0);
					if(pos != std::string::npos)
					{
						std::string ns = ns_and_class.substr(0, pos);
						std::string cls = ns_and_class.substr(ns.size()+2, ns_and_class.size());

						cppnamespace nspace(ns);
						getClass(cls).setNamespace(nspace);

					}
				}
				else
				{
					input->seekg(pos);
					//std::cout << "Peek: " << input->peek() << std::endl;
					buildFuncHeader(current, current_token);
				}
			}

		current = getChar();


	}


	postProcess();
}