Ejemplo n.º 1
0
void MembershipTableMgr::handleNormalJoinEvent(const MemberWrapper& member) {
  function_footprint();
  queue.push(member);
  if(joining) {
    DVLOG(0) << "$$$$$$$$$$$$$$$$$$$$$$$$$$";
    DVLOG(0) << "$$$$$$$$$$$$$$$$$$$$$$$$$$";
    DVLOG(0) << "current joining member queue size: " << queue.unsafe_size();
    DVLOG(0) << "$$$$$$$$$$$$$$$$$$$$$$$$$$";
    DVLOG(0) << "$$$$$$$$$$$$$$$$$$$$$$$$$$";
    return;
  }
  while(!queue.empty()) {
    joining.store(true);
    MemberWrapper joined_member;
    queue.try_pop(joined_member);
    // leading generate whole member table and send to joining member.
    auto wholeMemberTable = std::make_shared<WholeMembershipTableEvent>();
    genMembershipTable(*wholeMemberTable->mutable_table());
    ResultCode rs;
    rs = multicastMemberMessage(WHOLE_MEMBERSHIP_TABLE, wholeMemberTable);
    if (rs != RC_SUCCESS) {
      LOG(ERROR)<< getErrorDescription(rs);
      return;
    }
    // leading send delta member to all members.
    auto deltaMember = std::make_shared<DeltaMemberEvent>();
    deltaMember->set_position(findAddPos());
    deltaMember->mutable_member()->CopyFrom(joined_member.getMember());
    rs = multicastMemberMessage(DELTA_MEMBER_AND_JOIN_POSITION, deltaMember);
    if (rs != RC_SUCCESS) {
      LOG(ERROR)<< getErrorDescription(rs);
      return;
    }
  }
}
void TopNAction::registerTempKeyMessage(const uint32_t& partition, const std::string& typeName,
    const std::vector<FieldInfo>& fields) {
  DynamicTypeComposer composer;
  composer.setPackage("idgs.rdd.pb");
  composer.setName(typeName);

  DynamicMessage dmKey;
  dmKey.name = typeName;
  auto it = fields.begin();
  for (; it != fields.end(); ++ it) {
    DynamicField dyField = DynamicField("required", idgs::str::toLower(DataType_Name(it->type)), it->name);
    dmKey.addField(dyField);
  }

  composer.addMessage(dmKey);
  string fileName = RDD_DYNAMIC_PROTO_PATH + typeName + "_" + to_string(partition) + ".proto";
  composer.saveFile(fileName);

  auto helper = idgs_rdd_module()->getMessageHelper();
  auto code = helper->registerDynamicMessage(fileName);
  if (code != RC_SUCCESS) {
    LOG(ERROR)<< "Invalid message type, caused by " << getErrorDescription(code);
  }

  remove(fileName.c_str());
}
/*
 * Class:     net_contentobjects_fshook_win32_Win32FSHook
 * Method:    getErrorDesc
 * Signature: (J)Ljava/lang/String;
 */
JNIEXPORT jstring JNICALL Java_net_contentobjects_jnotify_win32_JNotify_1win32_getErrorDesc
(JNIEnv *env, jclass clazz, jlong errorCode)
{
    WCHAR buffer[1024];
    getErrorDescription(errorCode, buffer, sizeof(buffer) / sizeof(WCHAR));
    return env->NewString((jchar*)buffer, wcslen(buffer));
}
Ejemplo n.º 4
0
void ImuRosI::phidgetsDiagnostics(diagnostic_updater::DiagnosticStatusWrapper &stat)
{
  if (is_connected_)
  {
    stat.summary(diagnostic_msgs::DiagnosticStatus::OK, "The Phidget is connected.");
    stat.add("Device Serial Number", getDeviceSerialNumber());
    stat.add("Device Name", getDeviceName());
    stat.add("Device Type", getDeviceType());
  }
  else
  {
    stat.summary(diagnostic_msgs::DiagnosticStatus::ERROR, "The Phidget is not connected. Check the USB.");
  }

  if (error_number_ != 0)
  {
    stat.summary(diagnostic_msgs::DiagnosticStatus::ERROR, "The Phidget reports error.");
    stat.add("Error Number", error_number_);
    stat.add("Error message", getErrorDescription(error_number_));
  }
}
Ejemplo n.º 5
0
void SCsCodeErrorAnalyzer::showError(const QVector<SCsParserException> &exceptions) const
{

    if (mErrorTable == NULL)
        return;

	mErrorTable->clear();

	QVector<SCsParserException>::const_iterator it;
	for (it = exceptions.begin(); it != exceptions.end(); ++it)
	{
        QString description = getErrorDescription(*it);
        mErrorTable->addError(description, it->line(), it->positionInLine());
	}

	if (!exceptions.isEmpty())
		mErrorTable->show();
	else
		mErrorTable->hide();

}
Ejemplo n.º 6
0
void Phidget::errorHandler(int error)
{
	cout << "Phidget error " << error << getErrorDescription(error).c_str();
}
Ejemplo n.º 7
0
// returns: ERROR_OK, ERROR_INPUTOUPUT, ERROR_INTEGRITY
void extractDataToFile(LauncherProperties * props, WCHAR *output, int64t * fileSize, DWORD expectedCRC ) {
    if(isOK(props)) {
        DWORD * status = & props->status;
        HANDLE hFileRead = props->handler;
        int64t * size = fileSize;
        DWORD counter = 0;
        DWORD crc32 = -1L;
        HANDLE hFileWrite = CreateFileW(output, GENERIC_READ | GENERIC_WRITE, 0, 0, CREATE_ALWAYS, 0, hFileRead);
        
        if (hFileWrite == INVALID_HANDLE_VALUE) {
            WCHAR * err;
            writeMessageA(props, OUTPUT_LEVEL_DEBUG, 0, "[ERROR] Can`t create file ", 0);
            writeMessageW(props, OUTPUT_LEVEL_DEBUG, 0, output, 1);
            
            err = getErrorDescription(GetLastError());
            writeMessageA(props, OUTPUT_LEVEL_DEBUG, 0, "Error description : ", 0);
            writeMessageW(props, OUTPUT_LEVEL_DEBUG, 0, err, 1);
            
            showErrorW(props, OUTPUT_ERROR_PROP, 2, output, err);
            FREE(err);
            *status = ERROR_INPUTOUPUT;
            return;
        }
        if(props->restOfBytes->length!=0 && props->restOfBytes->bytes!=NULL) {
            //check if the data stored in restBytes is more than we neen
            // rest bytes contains much less than int64t so we operate here only bith low bits of size
            DWORD restBytesToWrite = (compare(size, props->restOfBytes->length)> 0 ) ? props->restOfBytes->length : size->Low;
            DWORD usedBytes = restBytesToWrite;
            
            char *ptr = props->restOfBytes->bytes;
            
            DWORD write = 0;
            while (restBytesToWrite >0) {
                WriteFile(hFileWrite, ptr, restBytesToWrite, &write, 0);
                update_crc32(&crc32, ptr, write);
                restBytesToWrite -= write;
                ptr +=write;
            }
            modifyRestBytes(props->restOfBytes, usedBytes);
            minus(size, usedBytes);
            
        }
        
        
        if(compare(size, 0) > 0 ) {
            DWORD bufferSize = props->bufsize;
            char * buf = newpChar(bufferSize);
            DWORD bufsize = (compare(size, bufferSize) > 0) ? bufferSize : size->Low;
            DWORD read = 0 ;
            //  printf("Using buffer size: %u/%u\n", bufsize, bufferSize);
            while (ReadFile(hFileRead, buf, bufsize, &read, 0) && read && compare(size, 0) > 0) {
                addProgressPosition(props, read);
                WriteFile(hFileWrite, buf, read, &read, 0);
                update_crc32(&crc32, buf, read);
                
                minus(size, read);
                
                if((compare(size, bufsize)<0) && (compare(size, 0)>0) ) {
                    bufsize = size->Low;
                }
                ZERO(buf, sizeof(char) * bufferSize);
                if(compare(size, 0)==0) {
                    break;
                }
                if((counter ++) % 20 == 0)  {
                    if(isTerminated(props)) break;
                }
                
            }
            if((compare(size, 0)>0 || read==0) && !isTerminated(props)) {
                // we could not read requested size
                * status = ERROR_INTEGRITY;
                writeMessageA(props, OUTPUT_LEVEL_DEBUG, 1,
                        "Can`t read data from file : not enought data", 1);
            }
            FREE(buf);
        }
        CloseHandle(hFileWrite);
        crc32=~crc32;
        if(isOK(props) && crc32!=expectedCRC) {
            writeDWORD(props, OUTPUT_LEVEL_DEBUG, 0, "expected CRC : ", expectedCRC, 1);
            writeDWORD(props, OUTPUT_LEVEL_DEBUG, 0, "real     CRC : ", crc32, 1);
            * status = ERROR_INTEGRITY;
            
        }
    }
}
      int client_run() {
        function_footprint();

        try {

          ResultCode resultCode;

          auto client = getTcpClientPool().getTcpClient(resultCode);
          if (resultCode != RC_SUCCESS) {
            cerr << "Get Client error: " << getErrorDescription(resultCode) << endl;
            return RC_ERROR;
          }

          // step 1, 2
          idgs::client::ClientActorMessagePtr clientActorMsg = make_shared<idgs::client::ClientActorMessage>();
          clientActorMsg->setDestActorId(test_server_id);
          clientActorMsg->setDestMemberId(ANY_MEMBER);
          clientActorMsg->setSourceActorId("client_actor_id");
          clientActorMsg->setSourceMemberId(CLIENT_MEMBER);
          clientActorMsg->setOperationName(start_work_operation);
          clientActorMsg->getRpcMessage()->set_payload("payload");
          ResultCode errorCode;
          idgs::client::ClientActorMessagePtr response;
          errorCode = client->sendRecv(clientActorMsg, response);
          if (errorCode != RC_SUCCESS) {
            cerr << "execute the command error: " << getErrorDescription(errorCode) << endl;
            client->close();
            return RC_ERROR;
          }
          DLOG(INFO) << "write message to server" << clientActorMsg->toString();
          // step 3, 4
          errorCode = client->receive(response);
          if (errorCode != RC_SUCCESS) {
            DLOG(INFO) << "get response error " << errorCode;
            return errorCode;
          }
          if (response->getOperationName() == sending_reponse_succ) {
            response->setOperationName(new_client_message_comes);
            response->setDestActorId(test_server_id);
            response->setSourceActorId("client_actor_id");
            response->setDestMemberId(response->getSourceMemberId());
            response->setChannel(TC_TCP);
            response->setSourceMemberId(CLIENT_MEMBER);

            ResultCode errorCode;
            idgs::client::ClientActorMessagePtr tcpResponse;
            errorCode = client->sendRecv(response, tcpResponse);
            DVLOG(2) << "after sendRecv";
            if (errorCode != RC_SUCCESS) {
              cerr << "execute the command error: " << getErrorDescription(errorCode) << endl;
              client->close();
              return RC_ERROR;
            }
            if (tcpResponse->getOperationName() == sending_total) {
              idgs::pb::Long l;
              tcpResponse->parsePayload(&l);
              test_server_count = l.value();
            }
            ++count;
          } else {
            std::cerr <<"Test client error, receive error server response" ;
            return RC_ERROR;
          }

          //while (1) {}
          //socket.close();

        } catch (std::exception& e) {
          std::cerr <<"Test client error" << e.what() << std::endl;
          return RC_ERROR;
        }
        return RC_SUCCESS;
      }