bool ExpandableBlockStreamExchangeEpoll::close()
{
	logging_->log("[%ld] Close: nexhausted lowers=%d, nlower=%d", state.exchange_id_, nexhausted_lowers, nlowers);

	CancelReceiverThread();

	CloseTheSocket();

	/* free the temporary resource/ */
	for (unsigned i = 0; i < nlowers; i++)
	{
		delete block_for_socket_[i];
		;
	}
	delete received_block_stream_;
	delete buffer;
	delete[] block_for_socket_;

	/* rest the status of this iterator instance, such that the following calling of open() and next() can
	 * act correctly.
	 */
	resetStatus();

	Environment::getInstance()->getExchangeTracker()->LogoutExchange(ExchangeID(state.exchange_id_, partition_offset));
	logging_->log("[%ld] ExchangeUpper is closed!", state.exchange_id_);

	return true;
}
Example #2
0
bool ExchangeMerger::Close() {
  LOG(INFO) << " exchange_merger_id = " << state_.exchange_id_ << " closed!"
            << " exhausted lower senders num = " << exhausted_lowers
            << " lower sender num = " << lower_num_ << std::endl;

  CancelReceiverThread();
  CloseSocket();
  for (unsigned i = 0; i < lower_num_; i++) {
    if (NULL != block_for_socket_[i]) {
      delete block_for_socket_[i];
      block_for_socket_[i] = NULL;
    }
  }
  if (NULL != block_for_deserialization) {
    delete block_for_deserialization;
    block_for_deserialization = NULL;
  }
  if (NULL != all_merged_block_buffer_) {
    delete all_merged_block_buffer_;
    all_merged_block_buffer_ = NULL;
  }

  /* rest the status of this iterator instance, such that the following calling
   * of open() and next() can act correctly.
   */
  ResetStatus();

  Environment::getInstance()->getExchangeTracker()->LogoutExchange(
      ExchangeID(state_.exchange_id_, partition_offset_));
  LOG(INFO) << "exchange merger id = " << state_.exchange_id_ << " is closed!"
            << std::endl;
  return true;
}
bool ExpandableBlockStreamExchange::close(){
	CancelReceiverThread();

	for(unsigned i=0;i<nlowers;i++){
		FileClose(this->socket_fd_lower_list[i]);
	}

	block_for_socket_->~BlockReadable();
	received_block_stream_->~BlockStreamBase();
	buffer->~BlockStreamBuffer();

	delete[] socket_fd_lower_list;

	CloseTheSocket();

	Environment::getInstance()->getExchangeTracker()->LogoutExchange(state.exchange_id);

	return true;
}