Ejemplo n.º 1
0
LogicalSector * getSectorFromCacheOrDisk1 (tSectorId sid) {
	char logBuf[BUFFSIZE];
	LogicalSector *ls;
	tSearchParm search;
	uint headPos;
	int ret = 0;

	ls = sector_BuildLogical(sid, NULL); /* Reserva memoria - usaba SECTOR_BLANK */
	if (isVdaAvailableCache())
			if ((ret = cache_Search (getVdaCache(), ls, sid)) == 1) 
					if(isInfoEnabled()) {
						sprintf_s(logBuf, BUFFSIZE,"[GET] Tiempo consumido: %.2f, Sectores leidos: %d (en cache), Cache Hit/Miss %d/%d", cache_getAccessTime(), sid, cache_getHitAverage(getVdaCache()), cache_getMissAverage(getVdaCache()));
						info(logBuf); 
					}
	if (ret != 1) {
				vdadisk_read (getDBFullPath(), ls, sid);
				/* Lo agrego a la cache para que este en la proxima lectura */
				if (isVdaAvailableCache())
					cache_Write (getVdaCache(), ls);
				headPos = disk_getHeadPos(getDiskParms());
				/* Realizo la simulacion */
				scanSector(getDiskParms(), &search, sid);
				if(isInfoEnabled()) {
					if (isVdaAvailableCache())
						sprintf_s(logBuf, BUFFSIZE,"[GET] Posicion cabezal: %d, Tiempo consumido: %.2f, Sectores leidos: %s, Cache Hit/Miss %d/%d", headPos, search_getTime(&search), search_getHistory(&search), cache_getHitAverage(getVdaCache()), cache_getMissAverage(getVdaCache()));
					else
						sprintf_s(logBuf, BUFFSIZE,"[GET] Posicion cabezal: %d, Tiempo consumido: %.2f, Sectores leidos: %s", headPos, search_getTime(&search), search_getHistory(&search));
						info(logBuf); 
					}
	}
	searchParmDestroy (&search);
	return ls;
}
Ejemplo n.º 2
0
	int main(void) {

		configure();

		//testFormat();
		//testCreate();
		//testCreatingBitVector();
		//testUpdateSize();
		//testGettingFileInformation();
		//testAddingSectors();
		//testListingFiles();
		//testFreeingSectors();
		//testGetCurrentSize();

		//testListImplementation();
		//testListImplementation2();

		if(isInfoEnabled())
			info("Conectando con modulo KSS");

		ListenSocket s = openClientConnection(getKssHost() , getKssPort());

		if(s == INVALID_SOCKET){
			error("no se puede abrir la coneccion");
			return EXIT_FAILURE;
		}

		if(isInfoEnabled())
			info("Quedando a la espera de peticiones para realizar operaciones FSS");

		RuntimeErrorValidator * validator ;
		MpsRequest * request = NULL;

		while(isFssRunningStatus()){
			validator = buildErrorSuccessValidator();
			request = receiveMpsRequest(s , validator);
			validator = buildErrorSuccessValidator();
			info("Reciviendo peticion MPS");

			if(isInfoEnabled())
				info(concatAll(3 , "Header.DescriptorId: '" , strndup(request->descriptorId , 16) , "'"));

			if(isInfoEnabled())
				info( concatAll(3 , "Payload.Arguments: '" , formatListToPreetyString(request->arguments) , "'"));

			if(isInfoEnabled())
				info(concatAll(3 , "Payload.OperationName: '" , request->operationName , "'"));

			executeOperation(s , request , validator);
		}

		return EXIT_SUCCESS;
	}
Ejemplo n.º 3
0
	void setupDirectoryIndexes(){
		if(existsFile(getDataDirectory())){
			if(isInfoEnabled()) info(concatAll( 3, "Usando " , getDataDirectory() , " como directorio de indices"));
		}else{
			if(isInfoEnabled()) info(concatAll(2 , "No existe el directorio " , getDataDirectory()));

			if(createDirectory(getDataDirectory())){
				if(isInfoEnabled()) info(concatAll(2 , "Se crea " , getDataDirectory()));
			}else{
				if(isInfoEnabled()) info(concatAll(2 , "No se pudo crear el directorio " , getDataDirectory()));
				killAndWait(1);
				return;
			}
		}
	}
Ejemplo n.º 4
0
	int main(void){
	
		configure();
		showInfo();

		if (!isVdaOfflineMode()){
			if( isInfoEnabled()) info( "Lanzando proceso servicio de comunicacion con KSS" );
			if(isKssConnectionOpen()) launchKssServiceThread();
		}
		
		info( "Lanzando proceso Shell" );
		help();
		
		Sleep(1000);
		do{
			processShell();

		}while(isVdaRunningStatus());
		
		finalizeResources();
		Sleep(1000);


		//testRandomKeys();

		return EXIT_SUCCESS;	
	}
Ejemplo n.º 5
0
	void configure(RuntimeErrorValidator * v){
		setupConfiguration(v);
		closingEvents();
		if(hasError(v)){
			return;
		}

		//setLoggingLevelEnabled(LOGGING_LEVEL_INFO);
		setFssRunningStatus(TRUE);
		setupDirectoryIndexes();

		if(isInfoEnabled())
			info("Conectando con modulo KSS");

		ListenSocket s = openClientConnection(getKssHost() , getKssPort());

		if(s == INVALID_SOCKET){
			setError(v , "no se puede abrir la coneccion");
			return;
		}

		MpsHandshake * handshake = buildMpsHandhake(generateRandomKey(16) , FSS_HANDSHAKE);
		handshake = sendAndReceiveMpsHandshake(handshake , s , v);

		if(handshake != NULL && handshake->statusCode == MPS_RESPONSE_STATUS_CODE_SUCCESS ){
			info(concatAll(2 , "Handshake realizado satisfactoriamente con DescriptorId: " , handshake->descriptorId));
			setFileSystemSocket(s);
		}else{
			setError(v , "Hubo un problema y no se pudo realizar el handshake");
			return;
		}
	}
Ejemplo n.º 6
0
	void launch(){
		RuntimeErrorValidator * validator = NULL;

		if(isInfoEnabled())
			info("Quedando a la espera de peticiones para realizar operaciones FSS");

		MpsMessage * request = NULL;

		while(isFssRunningStatus()){
			validator = buildErrorSuccessValidator();
			request = receiveMpsMessage(getFileSystemSocket(), validator);

			if(request == NULL || hasError(validator)){
				error("Se produjo un error en la recepcion, finalizando la aplicacion");
				close(getFileSystemSocket());
				exit(1);
			}

			if(isDebugEnabled())
				debug("Reciviendo peticion MPS");

			if(isDebugEnabled())
				debug(concatAll(3 , "Header.DescriptorId: '" , strndup(request->descriptorId , 16) , "'"));

			if(isDebugEnabled())
				debug( concatAll(3 , "Payload.Arguments: '" , formatListToPreetyString(request->commands) , "'"));

			if(isDebugEnabled())
				debug(concatAll(3 , "Payload.OperationName: '" , request->operationName , "'"));

			executeOperation(getFileSystemSocket() , request , validator);
		}

	}
	void * runShellServiceThread(void * arg){

		if(isInfoEnabled()){
			info("Quedando a la espera de conecciones Shell");
		}

		ServerSocket * serverSocket = openServerConnection(getShellPort());
		setShellServerSocket(serverSocket);
		ListenSocket listenSocket;
		ClientConnection * clientConnection;

		Thread thread;

		RuntimeErrorValidator * validator = NULL;
		do{
			listenSocket = acceptConnection(serverSocket);
			validator = buildErrorSuccessValidator();

			doHandshake(listenSocket , SHELL_HANDSHAKE , validator);

			if(!hasError(validator)){
				clientConnection = buildClientConnection(listenSocket);
				pthread_create(&thread , NULL , runServiceShellThread , clientConnection);
				clientConnection->servingThread = thread;
			}else{
				error("No se pudo lograr el handhsake entre el kss y el proceso remoto Shell");
			}

		}while(isKssRunningStatus());

		close(getShellServerSocket());
		return EXIT_SUCCESS;
	}
	void * runShellServiceThread(void * arg){

		if(isInfoEnabled()){
			info("Quedando a la espera de conecciones Shell");
		}

		ServerSocket * serverSocket = openServerConnection(getShellPort());
		ListenSocket listenSocket;
		ClientConnection * clientConnection;

		setShellServerConnection(serverSocket);

		Thread thread;

		do{
			listenSocket = acceptConnection(serverSocket);
			clientConnection = buildClientConnection(listenSocket);
			pthread_create(&thread , NULL , runServiceShellThread , clientConnection);
			clientConnection->servingThread = thread;

			//TODO: agregar a la lista de recursos este ClientConnection
			//TODO: representando a uno de los clinetes shell conectados

		}while(isKssRunningStatus());

		closeShellServerConnection();

		return EXIT_SUCCESS;
	}
Ejemplo n.º 9
0
void Logger::info(std::string message) {
	if (!isInfoEnabled()) {
		return;
	}

	appendAll("INFO", message);
}
Ejemplo n.º 10
0
	void * runFtpServiceThread(void * arg){

		ServerSocket * serverSocket = openServerConnection(getFtpsPort());
		setFtpServerSocket(serverSocket);
		ListenSocket listenSocket;
		ClientConnection * clientConnection;
		RuntimeErrorValidator * validator = buildErrorSuccessValidator();

		Thread thread;

		do{
			if(isKssOperationalStatus()){


				if(isInfoEnabled()){
					info("Quedando a la espera de conecciones FTP");
				}

				listenSocket = acceptConnection(serverSocket);
				doHandshake(listenSocket , FTP_HANDSHAKE , validator);

				if(hasError(validator)){
					error("No se pudo lograr el handhsake entre el kss y el proceso remoto FTPS.");
				} else {
					clientConnection = malloc(sizeof(ClientConnection));
					clientConnection->clientSocket = listenSocket;

					pthread_create(&thread , NULL , runServiceFtpsThread , clientConnection);
					clientConnection->servingThread = thread;
				}

			}else{

				if(isInfoEnabled()){
					info("Aguardando por estado operacional");
				}
				sleep(5);
			}

		}while(isKssRunningStatus());


		close(getFtpServerSocket());
		return EXIT_SUCCESS;
	}
Ejemplo n.º 11
0
/*!
    Returns \c true if a message of type \a msgtype for the category should be
    shown. Returns \c false otherwise.
*/
bool QLoggingCategory::isEnabled(QtMsgType msgtype) const
{
    switch (msgtype) {
    case QtDebugMsg: return isDebugEnabled();
    case QtInfoMsg: return isInfoEnabled();
    case QtWarningMsg: return isWarningEnabled();
    case QtCriticalMsg: return isCriticalEnabled();
    case QtFatalMsg: return true;
    }
    return false;
}
Ejemplo n.º 12
0
	void setupConfiguration(){

		if(isInfoEnabled()){
			info( "Inicializando la configuracion.");
			info(concat(getGlobalHeap() , 2 , 
				"Levantando la configurarcion del archivo " , 
				FTPS_CONFIGURATION_FILE));
		}

		loadConfigurationW( FTPS_CONFIGURATION_FILE , getGlobalHeap() , &processConfiguration);
	}
Ejemplo n.º 13
0
	void initializeKssConnection(){
		
		ListenSocket kssConnectionSocket;
		
		if( isInfoEnabled()) info( "Iniciando la conexion con el KSS");
		
		kssConnectionSocket = openConnectionSocket( getKssAddress() , getKssPort());
		
		setKssConnection( kssConnectionSocket );
	
		if( isInfoEnabled())
			if( isKssConnectionOpen() ){

				RuntimeErrorValidator * validator;
				List arguments ;
				MpsRequest * request ;
				MpsResponse * response ;

				info( concat(getGlobalHeap() , 4, 
					"Proceso VDA conectado con proceso remoto Kss en host " , 
					getKssAddress() , ":" , getKssPort()));

				validator = buildErrorSuccessValidator(getGlobalHeap());
				arguments = buildStringsListWithValues(getGlobalHeap() , 1, getVdaName());
			
				request = buildMpsRequest(generateRandomKey(16 , getGlobalHeap()) , 
					VDA_IDENTIFY_NAME , arguments , getGlobalHeap());
				
				response = sendAndReceiveMpsMessages(kssConnectionSocket , request , validator, getGlobalHeap());
			
				if(equalsStrings(response->statusCode , MPS_RESPONSE_STATUS_CODE_SUCCESS)){
					info(concat(getGlobalHeap() , 2 , "Proceso VDA identificado con el Kss satisfactoriamente bajo el nombre: " , getVdaName()));
				}else{
					error("El proceso no se pudo identificar con el Kss por lo que el Kss no lo reconoce como dispositivo");
				}				

			}else {
				info( "Proceso VDA trabajando en modo offline. Fallo la conexion con servicio KSS");
			}			
	}
Ejemplo n.º 14
0
	void setupConfiguration(){

		if(isInfoEnabled()){
			info( "Inicializando la configuracion");
			info(concat(getGlobalHeap() , 2 , 
				"Levantando la configurarcion del archivo " , 
				VDA_CONFIGURATION_FILE_NAME));
		}

		/**
		 * TODO: modificar la funcion para pasar el archivo
		 * directamente, de esta forma se puede validar si existe o no.
		 */		
		loadConfiguration( VDA_CONFIGURATION_FILE_NAME , getGlobalHeap() , &processConfiguration);
	}
Ejemplo n.º 15
0
void showInfo(void) {
	char logBuf[BUFFSIZE];
	if (isInfoEnabled()) {
		sprintf_s(logBuf, BUFFSIZE, "[SHOW] Tiempo medio de busqueda: %.2f ", disk_averageTime(getDiskParms()));
		info(logBuf); 
		sprintf_s(logBuf, BUFFSIZE, "[SHOW] Tiempo peor de busqueda: %.2f ", disk_worstTime(getDiskParms()));
		info(logBuf);
		info(concat(getGlobalHeap(), 2,"[SHOW] Tasa de transferencia: ", itoa_buf(disk_transferRate(getDiskParms()))));
		if (isVdaAvailableCache()) {
			sprintf_s(logBuf, BUFFSIZE, "[SHOW] Tiempo medio de acceso a la cache: %.2f", cache_getAccessTime());
			info(logBuf);
		}
		else info("[SHOW] Cache desactivada");
		sprintf_s(logBuf, BUFFSIZE, "[SHOW] Rango valido de sectores [0..%d]", disk_lastSectorId(getDiskParms()));
		info(logBuf);
	}
}
Ejemplo n.º 16
0
int putSectorOnDisk (LogicalSector * ls) {
	char logBuf[BUFFSIZE];
	tSearchParm search;
	uint headPos;
	int ret = 0;

	vdadisk_write (getDBFullPath(), ls);
	headPos = disk_getHeadPos(getDiskParms());
	/* Actualizo la cache si el sector esta en ella, sino hay bolonki despues al leer */
	if (cache_Search (getVdaCache(), NULL, ls->sectorId) == 1)
		cache_Write (getVdaCache(), ls);
	/* Realizo la simulacion */
	scanSector(getDiskParms(), &search, ls->sectorId);
	if(isInfoEnabled()) {
		sprintf_s(logBuf, BUFFSIZE,"[PUT] Posicion cabezal: %d, Tiempo consumido: %.2f, Sectores leidos: %s", headPos, search_getTime(&search), search_getHistory(&search));
		info(logBuf); 
		}
	searchParmDestroy (&search);
	return SECTOR_SIZE;
}
Ejemplo n.º 17
0
	void * runFssServiceThread(void * arg) {

		if(isInfoEnabled()){
			info("Quedando a la espera de conecciones FSS");
		}

		RuntimeErrorValidator * validator = buildErrorSuccessValidator();
		ServerSocket * serverSocket = openServerConnection(getFssListenPort());
		setFssServerSocket(serverSocket);
		ListenSocket clientSocket = acceptConnection(serverSocket);

		doHandshake(clientSocket , FSS_HANDSHAKE, validator);

		if(hasError(validator)){
			error(validator->errorDescription);
			return NULL;
		}

		setFileSystemConnection(clientSocket );
		close(serverSocket);

		return EXIT_SUCCESS;
	}
Ejemplo n.º 18
0
	void initializeDisk() {
		/* Inicializo la estructura contenedora de parametros del disco usada en calculos y simulacion. */
		/* Uso getters de vda-configuration.h, info que viene directamente del archivo de configuracion. */
		if( isInfoEnabled()) info( "Iniciando parametros del disco");
		diskParmInit (getDiskParms(), getVdaTrackCount(), getVdaSectorCount(), getiRpm(), getTrackDelay());
	}
Ejemplo n.º 19
0
	void initializeCache(){
		if(isInfoEnabled())	info( "Iniciando la cache" );
		setVdaCache();
	}
Ejemplo n.º 20
0
	void finalizeResources(){
		if( isInfoEnabled()) info( "Liberando recursos" );
		destroyHeap(getGlobalHeap());
		finalizeWinsock();
	}