Ejemplo n.º 1
0
ActionRow RollbackManager::actionRowFromRollbackAction(const RollbackAction & action)
{
	ActionRow row;

	row.id        = 0;
	row.actor     = getActorId(action.actor);
	row.timestamp = action.unix_time;
	row.type      = action.type;

	if (row.type == RollbackAction::TYPE_MODIFY_INVENTORY_STACK) {
		row.location = action.inventory_location;
		row.list     = action.inventory_list;
		row.index    = action.inventory_index;
		row.add      = action.inventory_add;
		row.stack    = action.inventory_stack;
		row.stack.id = getNodeId(row.stack.name);
	} else {
		row.x         = action.p.X;
		row.y         = action.p.Y;
		row.z         = action.p.Z;
		row.oldNode   = getNodeId(action.n_old.name);
		row.oldParam1 = action.n_old.param1;
		row.oldParam2 = action.n_old.param2;
		row.oldMeta   = action.n_old.meta;
		row.newNode   = getNodeId(action.n_new.name);
		row.newParam1 = action.n_new.param1;
		row.newParam2 = action.n_new.param2;
		row.newMeta   = action.n_new.meta;
		row.guessed   = action.actor_is_guess;
	}

	return row;
}
Ejemplo n.º 2
0
// 1) The request uri should be /actor_name/admin_module/admin_attributes?parameter=parameter_value,parameter=parameter_value
//                              /  root    /cell[0]     /   cell[1]      / parameters
//                                         /<-- request path --------------------------------------------------------------->/
void AdminAsyncServlet::doGet(idgs::http::server::HttpRequest& req) {
  VLOG(2) << "doGet for http req: " << req.getRequestPath();
  std::string actorName = req.getRootPath();

  std::shared_ptr<google::protobuf::Message> payload;
  if (!getPayload(req.getRequestPath(), payload) ) {
    LOG(ERROR) << "get pay load error for request " << req.getRequestPath();
    idgs::http::server::HttpResponse rep =
        idgs::http::server::HttpResponse::createReply(idgs::http::server::HttpResponse::bad_request, "get pay load error");
    handler(rep);
    return;
  }

  if (req.getBody() != "") {
    ///
  }

  idgs::actor::ActorMessagePtr actorMsg(new idgs::actor::ActorMessage);

  actorMsg->setSourceActorId(getActorId());
  int32_t localMemId = idgs::util::singleton<idgs::Application>::getInstance().getMemberManager()->getLocalMemberId();
  actorMsg->setSourceMemberId(localMemId);
  actorMsg->setOperationName("get");
  actorMsg->setPayload(payload);
  actorMsg->setDestActorId(actorName);
  actorMsg->setDestMemberId(actorMsg->getSourceMemberId());

  VLOG(3) << "has sent http actor message: " << actorMsg->toString();
  idgs::util::singleton<idgs::actor::RpcFramework>::getInstance().getActorFramework()->sendMessage(actorMsg);
}
Ejemplo n.º 3
0
const std::list<ActionRow> RollbackManager::getRowsSince(time_t firstTime, const std::string & actor)
{
	sqlite3_stmt *stmt_stmt = actor.empty() ? stmt_select : stmt_select_withActor;
	sqlite3_bind_int64(stmt_stmt, 1, firstTime);

	if (!actor.empty()) {
		sqlite3_bind_int(stmt_stmt, 2, getActorId(actor));
	}

	const std::list<ActionRow> & rows = actionRowsFromSelect(stmt_stmt);
	sqlite3_reset(stmt_stmt);

	return rows;
}
void DataAggregatorActor::handleDeleteResponse(const ActorMessagePtr& msg) {
  DVLOG_FIRST_N(2, 20) << "receive store remove response of member " << getActorId();
  auto response = dynamic_cast<idgs::store::pb::DeleteResponse*>(msg->getPayload().get());

  // error
  if (response->result_code() != idgs::store::pb::SRC_SUCCESS) {
    LOG(ERROR)<< "error in remove data to member " << msg->getSourceActorId();
    resultCode = response->result_code();
  }

  ++ responseCount;
  DVLOG_FIRST_N(2, 20) << "member " << msg->getSourceMemberId() << " response, left " << requestCount - responseCount << " members.";
  if (requestCount == responseCount) {
    DVLOG_FIRST_N(2, 20) << "all member response, send response to client.";

    auto globalResponse = make_shared<idgs::store::pb::DeleteResponse>();
    globalResponse->set_result_code(resultCode);
    sendResponse(OP_DELETE_RESPONSE, globalResponse);

    terminate();
  }
}
Ejemplo n.º 5
0
Task * SnpEffWorker::tick() {

    if (inputUrlPort->hasMessage()) {
        const QString url = takeUrl();
        CHECK(!url.isEmpty(), NULL);

        QString outputDir = FileAndDirectoryUtils::createWorkingDir(url, getValue<int>(OUT_MODE_ID), getValue<QString>(CUSTOM_DIR_ID), context->workingDir());
        U2OpStatusImpl os;
        outputDir = GUrlUtils::createDirectory(outputDir + SnpEffWorker::BASE_SNPEFF_SUBDIR, "_", os);

        SnpEffSetting setting;
        setting.inputUrl = url;
        setting.outDir = outputDir;
        setting.inFormat = getValue<QString>(INPUT_FORMAT);
        setting.outFormat = getValue<QString>(OUTPUT_FORMAT);
        setting.genome = getValue<QString>(GENOME);
        setting.updownLength = getValue<QString>(UPDOWN_LENGTH);
        setting.canon = getValue<bool>(CANON);
        setting.hgvs = getValue<bool>(HGVS);
        setting.lof = getValue<bool>(LOF);
        setting.motif = getValue<bool>(MOTIF);

        SnpEffTask *t = new SnpEffTask (setting);
        connect(new TaskSignalMapper(t), SIGNAL(si_taskFinished(Task*)), SLOT(sl_taskFinished(Task*)));

        QList<ExternalToolListener *> listeners = createLogListeners();
        listeners[0]->setLogProcessor(new SnpEffLogProcessor(monitor(), getActorId()));
        t->addListeners(listeners);

        return t;
    }

    if (inputUrlPort->isEnded()) {
        setDone();
        outputUrlPort->setEnded();
    }
    return NULL;
}
Ejemplo n.º 6
0
    return NULL;
}

void CallVariantsWorker::sl_taskFinished() {
    CallVariantsTask* t = qobject_cast<CallVariantsTask*>(sender());
    if (t->getState() != Task::State_Finished || t->isCanceled() || t->hasError()){
        return;
    }

    DataTypePtr mtype = output->getBusType();
    const QList<QVariantMap>& res = t->getResults();
    foreach(const QVariantMap &m, res) {
        cache.append(Message(mtype, m));
    }
    t->clearResults();
    monitor()->addOutputFile(t->getResultUrl(), getActorId());
}

void CallVariantsWorker::cleanup() {
}

void CallVariantsWorker::takeAssembly(U2OpStatus &os) {
    Message m = assemblyPort->lookMessage();
    CHECK(!m.isEmpty(), );

    QVariantMap data = m.getData().toMap();
    if (!data.contains(BaseSlots::URL_SLOT().getId())){
        os.setError(tr("Assembly URL slot is empty. Please, specify the URL slot"));
        return;
    }
Ejemplo n.º 7
0
void RollbackManager::migrate(const std::string & file_path)
{
	std::cout << "Migrating from rollback.txt to rollback.sqlite." << std::endl;

	std::ifstream fh(file_path.c_str(), std::ios::in | std::ios::ate);
	if (!fh.good()) {
		throw FileNotGoodException("Unable to open rollback.txt");
	}

	std::streampos file_size = fh.tellg();

	if (file_size < 10) {
		errorstream << "Empty rollback log." << std::endl;
		return;
	}

	fh.seekg(0);

	sqlite3_stmt *stmt_begin;
	sqlite3_stmt *stmt_commit;
	SQLOK(sqlite3_prepare_v2(db, "BEGIN", -1, &stmt_begin, NULL));
	SQLOK(sqlite3_prepare_v2(db, "COMMIT", -1, &stmt_commit, NULL));

	std::string bit;
	int i = 0;
	time_t start = time(0);
	time_t t = start;
	SQLRES(sqlite3_step(stmt_begin), SQLITE_DONE);
	sqlite3_reset(stmt_begin);
	do {
		ActionRow row;
		row.id = 0;

		// Get the timestamp
		std::getline(fh, bit, ' ');
		bit = trim(bit);
		if (!atoi(bit.c_str())) {
			std::getline(fh, bit);
			continue;
		}
		row.timestamp = atoi(bit.c_str());

		// Get the actor
		row.actor = getActorId(deSerializeJsonString(fh));

		// Get the action type
		std::getline(fh, bit, '[');
		std::getline(fh, bit, ' ');

		if (bit == "modify_inventory_stack") {
			row.type = RollbackAction::TYPE_MODIFY_INVENTORY_STACK;
			row.location = trim(deSerializeJsonString(fh));
			std::getline(fh, bit, ' ');
			row.list     = trim(deSerializeJsonString(fh));
			std::getline(fh, bit, ' ');
			std::getline(fh, bit, ' ');
			row.index    = atoi(trim(bit).c_str());
			std::getline(fh, bit, ' ');
			row.add      = (int)(trim(bit) == "add");
			row.stack.deSerialize(deSerializeJsonString(fh));
			row.stack.id = getNodeId(row.stack.name);
			std::getline(fh, bit);
		} else if (bit == "set_node") {
			row.type = RollbackAction::TYPE_SET_NODE;
			std::getline(fh, bit, '(');
			std::getline(fh, bit, ',');
			row.x       = atoi(trim(bit).c_str());
			std::getline(fh, bit, ',');
			row.y       = atoi(trim(bit).c_str());
			std::getline(fh, bit, ')');
			row.z       = atoi(trim(bit).c_str());
			std::getline(fh, bit, ' ');
			row.oldNode = getNodeId(trim(deSerializeJsonString(fh)));
			std::getline(fh, bit, ' ');
			std::getline(fh, bit, ' ');
			row.oldParam1 = atoi(trim(bit).c_str());
			std::getline(fh, bit, ' ');
			row.oldParam2 = atoi(trim(bit).c_str());
			row.oldMeta   = trim(deSerializeJsonString(fh));
			std::getline(fh, bit, ' ');
			row.newNode   = getNodeId(trim(deSerializeJsonString(fh)));
			std::getline(fh, bit, ' ');
			std::getline(fh, bit, ' ');
			row.newParam1 = atoi(trim(bit).c_str());
			std::getline(fh, bit, ' ');
			row.newParam2 = atoi(trim(bit).c_str());
			row.newMeta   = trim(deSerializeJsonString(fh));
			std::getline(fh, bit, ' ');
			std::getline(fh, bit, ' ');
			std::getline(fh, bit);
			row.guessed = (int)(trim(bit) == "actor_is_guess");
		} else {
			errorstream << "Unrecognized rollback action type \""
				<< bit << "\"!" << std::endl;
			continue;
		}

		registerRow(row);
		++i;

		if (time(0) - t >= 1) {
			SQLRES(sqlite3_step(stmt_commit), SQLITE_DONE);
			sqlite3_reset(stmt_commit);
			t = time(0);
			std::cout
				<< " Done: " << static_cast<int>((static_cast<float>(fh.tellg()) / static_cast<float>(file_size)) * 100) << "%"
				<< " Speed: " << i / (t - start) << "/second     \r" << std::flush;
			SQLRES(sqlite3_step(stmt_begin), SQLITE_DONE);
			sqlite3_reset(stmt_begin);
		}
	} while (fh.good());
	SQLRES(sqlite3_step(stmt_commit), SQLITE_DONE);
	sqlite3_reset(stmt_commit);

	SQLOK(sqlite3_finalize(stmt_begin));
	SQLOK(sqlite3_finalize(stmt_commit));

	std::cout
		<< " Done: 100%                                  " << std::endl
		<< "Now you can delete the old rollback.txt file." << std::endl;
}
Ejemplo n.º 8
0
    }
}

void SnpEffWorker::sl_taskFinished(Task *task) {
    CHECK(!task->hasError(), );
    CHECK(!task->isCanceled(), );

    QString url = getTargetTaskUrl(task);
    CHECK(!url.isEmpty(), );

    sendResult(url);
    monitor()->addOutputFile(url, getActorId());

    QString summary = getSummaryUrl(task);
    CHECK(!summary.isEmpty(), );
    monitor()->addOutputFile(summary, getActorId(), true);
}

QString SnpEffWorker::takeUrl() {
    const Message inputMessage = getMessageAndSetupScriptValues(inputUrlPort);
    if (inputMessage.isEmpty()) {
        outputUrlPort->transit();
        return "";
    }

    const QVariantMap data = inputMessage.getData().toMap();
    return data[BaseSlots::URL_SLOT().getId()].toString();
}

void SnpEffWorker::sendResult(const QString &url) {
    const Message message(BaseTypes::STRING_TYPE(), url);
void DataAggregatorActor::handleGlobalTruncate(const idgs::actor::ActorMessagePtr& msg) {
  DVLOG_FIRST_N(2, 20) << "multicast store truncate operation with actor id : " << getActorId();
  clientMsg = msg;
  resultCode = idgs::store::pb::SRC_SUCCESS;
  multicast(msg, ACTORID_STORE_SERVCIE, OP_INTERNAL_TRUNCATE);
}