summaryrefslogtreecommitdiff
path: root/TAO/orbsvcs/tests/LoadBalancing/Hash_Replica_i.cpp
blob: ecc7970f1266df4e019a158e6f74d713a7466a42 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// -*- C++ -*-
// $Id$

#include "ace/ACE.h"

#include "Hash_Replica_i.h"
#include "Hash_ReplicaControl.h"

Hash_Replica_Impl::Hash_Replica_Impl (Hash_ReplicaControl *control)
  : control_ (control),
    reject_requests_ (0)
{
  // Nothing else
}

CORBA::ULong
Hash_Replica_Impl::do_hash (const char *str,
                            CORBA::Environment &ACE_TRY_ENV)
  ACE_THROW_SPEC ((CORBA::SystemException))
{
  if (this->reject_requests_)
    {
      this->control_->request_rejected (ACE_TRY_ENV);
      ACE_CHECK_RETURN (0);
      return 0;
    }

  this->control_->request_received ();

  // Return the hash.
  return ACE::hash_pjw (str);
}

void
Hash_Replica_Impl::reject_requests (int reject)
{
  this->reject_requests_ = reject;
}