Пример #1
0
static void printEncoders(int fd, uint32_t* ids, uint32_t count) {
	int i;

	for (i = 0; i < count; i++) {
		drmModeEncoder *enc;
		enc = drmModeGetEncoder(fd, ids[i]);
		fprintf(stdout, "      Encoder %u:\n", enc->encoder_id);
		fprintf(stdout, "        Type: %s\n", getEncoderType(enc->encoder_type));
		fprintf(stdout, "        CRTC: %u\n", enc->crtc_id);
		fprintf(stdout, "        Possible CRTCs: %1$u, %1$#08x, %1$#016o, %2$s\n", enc->possible_crtcs, bitList(enc->possible_crtcs));
		fprintf(stdout, "        Possible Clones: %1$u, %1$#08x, %1$#016o, %2$s\n", enc->possible_clones, bitList(enc->possible_clones));
		fprintf(stdout, "\n");
		drmModeFreeEncoder(enc);
	}
}
/*!
	@brief Executes operations of a Checkpoint for transaction thread.
*/
void CheckpointOperationHandler::operator()(EventContext &ec, Event &ev) {
	try {
		util::StackAllocator &alloc = ec.getAllocator();
		util::StackAllocator::Scope scope(alloc);

		EventByteInStream in = ev.getInStream();

		const PartitionId pId = ev.getPartitionId();
		const PartitionGroupId pgId =
			checkpointService_->getPGConfig().getPartitionGroupId(pId);

		int32_t mode;
		CheckpointId cpId;
		in >> mode;
		in >> cpId;

		const bool checkpointReady =
			dataStore_->isRestored(pId) && chunkManager_->existPartition(pId);

		WATCHER_START;
		switch (ev.getType()) {
		case CLEANUP_CP_DATA:
			chunkManager_->cleanCheckpointData(pgId);
			break;


		case PARTITION_GROUP_START:

			checkpointService_->setCurrentCpGrpId(pgId);

			chunkManager_->startCheckpoint(pgId, cpId);
			logManager_->prepareCheckpoint(pgId, cpId);
			break;

		case PARTITION_START:

			checkpointService_->setCurrentCpPId(pId);

			if (checkpointReady) {
				chunkManager_->startCheckpoint(pId);
			}
			writeCheckpointStartLog(alloc, mode, pgId, pId, cpId);
			writeChunkMetaDataLog(
				alloc, mode, pgId, pId, cpId, checkpointReady);
			break;

		case COPY_CHUNK:
			chunkManager_->copyChunk(pId);
			break;

		case PARTITION_END:
			chunkManager_->endCheckpoint(pId);

			checkpointService_->setCurrentCpPId(UNDEF_PARTITIONID);

			checkpointService_->setCurrentCheckpointId(
				pId, logManager_->getLastCheckpointId(pgId));
			if (cpId == 0) {
				logManager_->setAvailableStartLSN(pId, cpId);
			}

			break;

		case PARTITION_GROUP_END: {
			util::XArray<uint8_t> bitList(alloc);
			util::XArray<uint8_t> binaryLogBuf(alloc);

			chunkManager_->endCheckpoint(pgId, cpId);
			chunkManager_->flush(pgId);

			checkpointService_->setCurrentCpGrpId(UINT32_MAX);


			BitArray &validBitArray = chunkManager_->getCheckpointBit(pgId);

			{
				const PartitionId startPId =
					checkpointService_->getPGConfig().getGroupBeginPartitionId(
						pgId);
				const PartitionId endPId =
					checkpointService_->getPGConfig().getGroupEndPartitionId(
						pgId);
				for (PartitionId pId = startPId; pId < endPId; pId++) {
					checkpointService_->lsnInfo_.setLsn(
						pId, logManager_->getLSN(pId));  
				}
			}
			logManager_->putCheckpointEndLog(binaryLogBuf,
				checkpointService_->getPGConfig().getGroupBeginPartitionId(
					pgId),
				validBitArray);

			logManager_->writeBuffer(pgId);
			logManager_->flushFile(pgId);
			logManager_->postCheckpoint(
				pgId);  

			{
				PartitionTable *pt = checkpointService_->getPartitionTable();
				util::XArray<uint8_t> binaryLogRecords(alloc);
				CheckpointId cpId = logManager_->getFirstCheckpointId(pgId);
				logManager_->updateAvailableStartLsn(
					pt, pgId, binaryLogRecords, cpId);

				const PartitionId startPId =
					checkpointService_->getPGConfig().getGroupBeginPartitionId(
						pgId);
				const PartitionId endPId =
					checkpointService_->getPGConfig().getGroupEndPartitionId(
						pgId);
				clusterService_->requestUpdateStartLsn(
					ec, ec.getAllocator(), startPId, endPId);
			}

			if (mode == CP_SHUTDOWN) {
				logManager_->writeBuffer(
					pgId);  
				logManager_->flushFile(
					pgId);  
			}
		} break;
		}
		WATCHER_END_3(getEventTypeName(ev.getType()), pId, pgId);
	}
	catch (std::exception &e) {
		clusterService_->setError(ec, &e);
		GS_RETHROW_SYSTEM_ERROR(e, "Group checkpoint failed. (reason="
									   << GS_EXCEPTION_MESSAGE(e) << ")");
	}
}