Ejemplo n.º 1
0
Int16 SqlSealogEvent::sendEvent(Int16 eventId, Lng32 slSeverity)
{
  Int32 rc = 0;
#ifndef SP_DIS
  char eventidStr[10]="        ";
  Lng32 eventidLen = 0;
  str_sprintf(eventidStr,"10%d%06d",SQEVL_SQL,eventId);
  str_strip_blanks(eventidStr,eventidLen);
  Lng32 eventIdVal = (Lng32)str_atoi(eventidStr,eventidLen);
   common::event_header * eventHeader = sqlInfoEvent_.mutable_header();
  common::info_header * infoHeader = eventHeader->mutable_header();  

   rc = initAMQPInfoHeader(infoHeader, SQEVL_SQL);
   if (rc)
     //add trace log
     return rc;
  sqlInfoEvent_.mutable_header()->set_event_id(eventIdVal);
  sqlInfoEvent_.mutable_header()->set_event_severity(slSeverity);
  setExperienceLevel("ADVANCED");
  setTarget("LOGONLY");

  AMQPRoutingKey routingKey(SP_EVENT, SP_SQLPACKAGE,  SP_INSTANCE, 
                              SP_PUBLIC,  SP_GPBPROTOCOL,  "info_event"); 
  try {
    rc = sendAMQPMessage(true, sqlInfoEvent_.SerializeAsString(), SP_CONTENT_TYPE_APP, routingKey);
  } catch(...) {
    rc = -1;
  }
#endif
  return rc;
}
Ejemplo n.º 2
0
// no open connections
int test2()
{   
    int error = 0;
    wrapper::test event;
    event.set_data(1);
    AMQPRoutingKey routingKey(SP_EVENT, "wrapper", SP_INSTANCE, SP_PUBLIC,"test");
    error = sendAMQPMessage( event.SerializeAsString(), SP_CONTENT_TYPE_APP, routingKey);

   return error;
}
Ejemplo n.º 3
0
// will explicitly create a connection, then destroy it for further tests
int test1()
{
    int error = 0;
    error = createAMQPConnection();
    if (error)
       return error;

    wrapper::test event;
    event.set_data(2);
    AMQPRoutingKey routingKey(SP_EVENT, "wrapper", SP_INSTANCE, SP_PUBLIC,"test");
    error = sendAMQPMessage( event.SerializeAsString(), SP_CONTENT_TYPE_APP, routingKey);
    if (error)
        return error;

    error = closeAMQPConnection();
    return error;
}
Ejemplo n.º 4
0
// Don't log this on Windows since the repository table does not exist
Int32 CompilerTrackingInfo::logIntervalInRepository()
{
#ifdef SP_DIS
   return 0;
#else
   // declare a stack variable and populate
   sql::tracking_compilers trc_row;

   Int32 rc;
   if (!isAMQPConnectionEstablished())
   {
      rc = createAMQPConnection (NULL, -1);
      if (rc)
         return rc;
      AMQPConnectionEstablished(TRUE);
      
   }

   // the pointer to the process info for this tracker
   CmpProcess *p = processInfo_;
   CMPASSERT( NULL != p );

   // ============================================
   // -- start filling up the message structure --
   // ============================================
  
   // -- compiler Id
   char compilerId[COMPILER_ID_LEN];
   memset (compilerId, '\0', COMPILER_ID_LEN);
   p->getCompilerId(compilerId);
   trc_row.set_compiler_id(compilerId);

   // interval start time
   trc_row.set_interval_start_lct_ts(beginIntervalTimeUEpoch());

   // -- the CPU usage of this interval
   trc_row.set_interval_path_len(cpuPathLength());

   // -- longest CPU path length for single compile
   // -- within this interval
   trc_row.set_longest_compile_path(longestCompile());

   // -- age of compiler being tracked
   trc_row.set_compiler_age(compilerAge());

   // -- number of sessions during this interval
   trc_row.set_num_sessions(sessionCount());

   // -- largest size of the statement heap so far
   trc_row.set_stmt_heap_hwtr_mark(stmtHeapIntervalWaterMark());

   // -- number of bytes currently allocated for the
   // -- context heap of this process
   trc_row.set_context_heap_size(cxtHeapCurrentSize());

   // -- largest size of the context heap so far
   trc_row.set_context_heap_hwtr_mark(cxtHeapIntervalWaterMark());

   // -- number of bytes currently allocated for the
   // -- system heap of this process
   trc_row.set_system_heap_size(p->getCurrentSystemHeapSize());

   // -- largest size of the system heap so far
   trc_row.set_system_heap_hwtr_mark(systemHeapIntervalWaterMark());

   // -- number of bytes currently allocated for the
   // -- metadata cache
   trc_row.set_metadata_cache_size(metaDataCacheCurrentSize());

   // -- largest size of the metadata cache so far
   trc_row.set_metadata_cache_hwtr_mark(metaDataCacheIntervalWaterMark());

   // -- number of hits on the metadata cache
   trc_row.set_metadata_cache_hits(metaDataCacheHits());

   // -- number of misses on the metadata cache
   trc_row.set_metadata_cache_lookups(metaDataCacheLookups());

   // -- number of bytes currently allocated for the
   // -- query cache
   trc_row.set_query_cache_size(qCacheCurrentSize());

   // -- largest size of the query cache so far
   trc_row.set_query_cache_hwtr_mark(qCacheIntervalWaterMark());

   // -- number of hits on the query cache
   trc_row.set_query_cache_hits(qCacheHits());

   // -- number of misses on the query cache
   trc_row.set_query_cache_lookups(qCacheLookups());

   // -- number of bytes currently allocated for the
   // -- histogram cache
   trc_row.set_histogram_cache_size(hCacheCurrentSize());

   // -- largest size of the histogram cache so far
   trc_row.set_histogram_cache_hwtr_mark(hCacheIntervalWaterMark());

   // -- number of hits on the histogram cache
   trc_row.set_histogram_cache_hits(hCacheHits());

   // -- number of misses on the histogram cache
   trc_row.set_histogram_cache_lookups(hCacheLookups());

   // -- number of compiled queries (DDL and DML)
   trc_row.set_num_queries_compiled(successfulQueryCount());

   // -- number of failed compilations
   trc_row.set_num_failed_queries(failedQueryCount());

   // -- number of queries compiled successfully
   // -- but with warnings (2053 and 2078)
   trc_row.set_num_caught_exceptions(caughtExceptionCount());

   // -- the number of recompiles
   trc_row.set_num_recompiles(qCacheRecompiles());

   // -- extend any new counters
   trc_row.set_compiler_info(compilerInfo());

   // ============================================
   //  -- done filling up the message structure --
   // ============================================
  
   // populate the info header
   common::info_header *infoHeader = NULL;
   infoHeader = trc_row.mutable_header();
   rc =  initAMQPInfoHeader(infoHeader, SQEVL_SQL);
   if (rc)
   {
      closeAMQPConnection();
      AMQPConnectionEstablished(FALSE);
      return rc;
      
   }

   // set the routing key and send the message
   AMQPRoutingKey routingKey (SP_HEALTH_STATE, SP_SQLPACKAGE, SP_INSTANCE, SP_PUBLIC, 
                              SP_GPBPROTOCOL, "tracking_compilers");
   try {
     rc = sendAMQPMessage (true, trc_row.SerializeAsString(), 
                           SP_CONTENT_TYPE_APP, routingKey);
   
     if (rc) throw 1;
   } catch (...) {
     if (rc == SP_SUCCESS) rc = SP_SEND_FAILED; 
     closeAMQPConnection();
     AMQPConnectionEstablished(FALSE);
   }
  
   return rc;
#endif
}
Ejemplo n.º 5
0
 Int32 SQLMXLoggingArea::logSQLMXEventForError( ULng32 sqlcode, 
                                        const char* experienceLevel,
                                        const char* severityLevel,
                                        const char* eventTarget,
					const char *msgTxt,
					const char* sqlId,
					const Lng32 Int0,
					const Lng32 Int1,
					const Lng32 Int2,
					const Lng32 Int3,
					const Lng32 Int4,
				        const char *String0,
					const char * String1,
					const char * String2,
					const char * String3,
					const char * String4,
					const char * serverName,
					const char * connectionName,
					const char * constraintCatalog,
					const char * constraintSchema,
					const char * constraintName,
					const char * triggerCatalog,
					const char * triggerSchema,
					const char *triggerName,
					const char *catalogName,
					const char *schemaName,
					const char *tableName,
					const char *columnName,
					const Int64 currTransid,
					const Lng32 rowNumber,
					const Lng32 platformCode,
					NABoolean isWarning	
					)
{
  Int32 rc = 0;
  // sealog logging of sql error events
  // declare a event stack variable and populate
#ifndef SP_DIS
  bool lockedMutex = lockMutex();

  sql::error_event sql_error_event;
  Int32 qpidNodePort = atoi(getenv("QPID_NODE_PORT"));

  common::event_header * eventHeader = sql_error_event.mutable_header();
  common::info_header * infoHeader = eventHeader->mutable_header();  


  if (!SQLMXLoggingArea::establishedAMQPConnection())
    {
      rc = createAMQPConnection(NULL,-1);
      if (rc)
      {
        if (lockedMutex)
          unlockMutex();
	return rc;
      }
      establishedAMQPConnection_ = TRUE;
    }
 

  char eventidStr[10]="        ";
  Lng32 eventidLen = 0;
  str_sprintf(eventidStr,"10%d%06d",SQEVL_SQL,sqlcode);
  str_strip_blanks(eventidStr,eventidLen);
  Lng32 eventIdVal = (Lng32)str_atoi(eventidStr,eventidLen);
 
  sql_error_event.mutable_header()->set_event_id(eventIdVal);
  sql_error_event.mutable_header()->set_event_severity(sqlToSLSeverity(severityLevel, isWarning));

 
  sql_error_event.set_sqlcode(sqlcode);
  if (sqlId)
    sql_error_event.set_sqlid(sqlId);
  else
    {
      SB_Phandle_Type myphandle;
      XPROCESSHANDLE_GETMINE_(&myphandle);
      char charProcHandle[200];
      char myprocname[30];
      Int32 mycpu,mypin,mynodenumber=0;
      short myproclength = 0;
      XPROCESSHANDLE_DECOMPOSE_(&myphandle, &mycpu, &mypin, &mynodenumber,NULL,100, NULL, myprocname,100, &myproclength); 
      myprocname[myproclength] = '\0';
      str_sprintf(charProcHandle,"%d,%d,%d,%s",mycpu,mypin,mynodenumber,myprocname);
      sql_error_event.set_sqlid(charProcHandle);
    }
  sql_error_event.set_message_text(msgTxt);
  sql_error_event.set_err_experience_level(experienceLevel);
  sql_error_event.set_err_target(eventTarget);
  sql_error_event.set_int0(Int0);
  sql_error_event.set_int1(Int1);
  sql_error_event.set_int2(Int2);
  sql_error_event.set_int3(Int3);
  sql_error_event.set_int4(Int4);

  if (String0)
    sql_error_event.set_string0(String0);
  if (String1)
    sql_error_event.set_string1(String1);
  if (String2)
    sql_error_event.set_string2(String2);
  if (String3)
    sql_error_event.set_string3(String3);
  if (String4)
    sql_error_event.set_string4(String4);
  //LCOV_EXCL_START - unused members of diags are
  if (serverName)
    sql_error_event.set_server_name(serverName);
  if (connectionName)
    sql_error_event.set_connection_name(connectionName);
  //LCOV_EXCL_STOP
  if (constraintCatalog)
    sql_error_event.set_constraint_catalog(constraintCatalog);
  if (constraintSchema)
    sql_error_event.set_constraint_schema(constraintSchema);
  if (constraintName)
    sql_error_event.set_constraint_name(constraintName);
  if (triggerCatalog)
    sql_error_event.set_trigger_catalog(triggerCatalog);
  if (triggerSchema)
    sql_error_event.set_trigger_schema(triggerSchema);
  if (triggerName)
    sql_error_event.set_trigger_name(triggerName);
  
  if (catalogName)
    sql_error_event.set_catalog_name(catalogName);
  if (schemaName)
    sql_error_event.set_schema_name(schemaName);
  if (tableName)
    sql_error_event.set_table_name(tableName);
  if (columnName)
    sql_error_event.set_column_name(columnName);
  
  sql_error_event.set_current_transid(currTransid);
  sql_error_event.set_row_number(rowNumber);  
  sql_error_event.set_platform_error_code(platformCode);

  rc =  initAMQPInfoHeader(infoHeader, SQEVL_SQL);
  if (rc)
    {
      closeAMQPConnection();
      establishedAMQPConnection_ = FALSE;
      if (lockedMutex)
        unlockMutex();
      return rc;
    }
 
  AMQPRoutingKey routingKey(SP_EVENT, SP_SQLPACKAGE,  SP_INSTANCE, 
                              SP_PUBLIC,  SP_GPBPROTOCOL,  "error_event"); 
  try { 
    rc = sendAMQPMessage(true, sql_error_event.SerializeAsString(), 
                         SP_CONTENT_TYPE_APP, routingKey);
    if (rc) throw 1;
  } catch (...) {
    closeAMQPConnection(); 
    establishedAMQPConnection_ = FALSE;
    if (!rc) rc = SP_SEND_FAILED;
    if (lockedMutex)
       unlockMutex();
    return rc;
  }

  if (lockedMutex)
    unlockMutex();
#else
  rc = 0;
#endif

  return rc;

}