00001 /******************************************************************************* 00002 * ALMA - Atacama Large Millimiter Array 00003 * (c) NRAO, 2009 00004 * Copyright by NRAO (in the framework of the ALMA collaboration) 00005 * All rights reserved 00006 * 00007 * This library is free software; you can redistribute it and/or 00008 * modify it under the terms of the GNU Lesser General Public 00009 * License as published by the Free Software Foundation; either 00010 * version 2.1 of the License, or (at your option) any later version. 00011 * 00012 * This library is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00015 * Lesser General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU Lesser General Public 00018 * License along with this library; if not, write to the Free Software 00019 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00020 * 00021 * 00022 * "@(#) $Id:" 00023 */ 00024 00025 #ifndef _ACS_LOG_SERVICE_IMPL_H_ 00026 #define _ACS_LOG_SERVICE_IMPL_H_ 00027 00028 #include <ace/Synch.h> 00029 #include <logging_idlS.h> 00030 #include "loggingACSLog_i.h" 00031 00038 class AcsLogServiceImpl: public ACSLog_i, 00039 public POA_Logging::AcsLogService 00040 { 00041 public : 00042 AcsLogServiceImpl (CORBA::ORB_ptr orb, 00043 PortableServer::POA_ptr poa, 00044 TAO_LogMgr_i &logmgr_i, 00045 DsLogAdmin::LogMgr_ptr factory, 00046 DsLogAdmin::LogId id); 00047 00048 ~AcsLogServiceImpl(); 00049 00050 void writeRecords (const ::Logging::XmlLogRecordSeq & xmlLogRecords); 00051 Logging::LogStatistics getStatistics(); 00053 void set_logging_supplier(ACSStructuredPushSupplier* supplier); 00054 00055 00056 protected: 00066 class LogRecordBatch 00067 { 00068 private: 00070 ::Logging::XmlLogRecordSeq *buffer_; 00072 ::Logging::XmlLogRecordSeq buffer[3]; 00074 volatile unsigned int size_; 00075 ACSStructuredPushSupplier* loggingSupplier_; 00077 ACE_SYNCH_MUTEX mutex_; 00079 ACE_SYNCH_MUTEX batchMutex_; 00080 ACE_SYNCH_CONDITION waitCond_; 00081 volatile bool shutdown_; 00083 int nBuff; 00085 ::Logging::XmlLogRecordSeq *tmpBuffer; 00087 unsigned int tmpSize; 00088 00090 void sendRecords(::Logging::XmlLogRecordSeq *reclist); 00092 int svc(); 00093 00094 public: 00096 LogRecordBatch(); 00098 ~LogRecordBatch(); 00100 void sendRecords(); 00103 void add(const ::Logging::XmlLogRecordSeq *reclist); 00105 static void* worker(void *); 00106 void set_logging_supplier(ACSStructuredPushSupplier* supplier); 00107 }; 00108 00109 LogRecordBatch recordBatch; 00110 00111 }; 00112 00113 #endif