예제 #1
0
파일: merger.c 프로젝트: bhohbaum/moosefs
int merger_loop(void) {
	int status;
	uint8_t perc,etaok;
	uint32_t eta;
	uint64_t st,cu;
	hentry h;

	perc = 0;
	eta = 0;
	etaok = 0;
	st = get_usectime();
	while (heapsize) {
		if ((heap[0].nextid%2497)==0 && lastlv>firstlv) {
			if (heap[0].nextid<(int64_t)firstlv) {
				perc = 0;
				eta = 0;
				etaok = 0;
				st = get_usectime();
			} else if (heap[0].nextid>(int64_t)lastlv) {
				perc = 100;
				eta = 0;
				etaok = 1;
			} else {
				cu = get_usectime();
				perc = (heap[0].nextid - firstlv) * 100 / (lastlv - firstlv);
				eta = ((lastlv - heap[0].nextid) * (cu - st) / (heap[0].nextid - firstlv)) / 1000000U;
				etaok = 1;
			}
			printf("progress: current change: %"PRIu64" (first:%"PRIu64" - last:%"PRIu64" - %"PRIu8"%%",heap[0].nextid,firstlv,lastlv,perc);
			if (etaok) {
				printf(" - ETA:%02u:%02us)\r",(unsigned int)(eta/60),(unsigned int)(eta%60));
			} else {
				printf(" - ETA:__:__s)\r");
			}
			fflush(stdout);
		}
//		printf("current id: %"PRIu64" / %s\n",heap[0].nextid,heap[0].ptr);
		if ((status=restore(heap[0].filename,heap[0].nextid,heap[0].ptr))<0) {
			while (heapsize) {
				heapsize--;
				merger_delete_entry();
			}
			printf("\n");
			return status;
		}
		merger_nextentry(0);
		if (heap[0].nextid<0) {
			heapsize--;
			h = heap[0];
			heap[0] = heap[heapsize];
			heap[heapsize] = h;
			merger_delete_entry();
		}
		merger_heap_sort_down();
	}
	printf("progress: current change: %"PRIu64" (first:%"PRIu64" - last:%"PRIu64" - 100%% - ETA:finished)\n",lastlv,firstlv,lastlv);
	return 0;
}
예제 #2
0
파일: merger.c 프로젝트: bhohbaum/moosefs
int merger_start(uint32_t files,char **filenames,uint64_t maxhole,uint64_t maxlastlv) {
	uint32_t i;
	heapsize = 0;
	heap = (hentry*)malloc(sizeof(hentry)*files);
	if (heap==NULL) {
		return -1;
	}
	for (i=0 ; i<files ; i++) {
		merger_new_entry(filenames[i]);
//		printf("file: %s / firstid: %"PRIu64"\n",filenames[i],heap[heapsize].nextid);
		if (heap[heapsize].nextid<0) {
			merger_delete_entry();
		} else {
			heapsize++;
			merger_heap_sort_up();
		}
	}
	maxidhole = maxhole;
	lastlv = maxlastlv;
	firstlv = fs_getversion();
//	for (i=0 ; i<heapsize ; i++) {
//		printf("heap: %u / firstid: %"PRIu64"\n",i,heap[i].nextid);
//	}
	return 0;
}
예제 #3
0
파일: merger.c 프로젝트: pedia/mfs
int merger_loop(void) {
	int status;
	hentry h;
	while (heapsize) {
//		printf("current id: %"PRIu64" / %s\n",heap[0].nextid,heap[0].ptr);
		if ((status=restore(heap[0].filename,heap[0].nextid,heap[0].ptr))<0) {
			while (heapsize) {
				heapsize--;
				merger_delete_entry();
			}
			return status;
		}
		merger_nextentry(0);
		if (heap[0].nextid==0) {
			heapsize--;
			h = heap[0];
			heap[0] = heap[heapsize];
			heap[heapsize] = h;
			merger_delete_entry();
		}
		merger_heap_sort_down();
	}
	return 0;
}