OpenSplice Java 5 DCPS  v6.x
OpenSplice Java 5 OpenSplice Data Distribution Service Data-Centric Publish-Subscribe API
ResourceLimitsImpl.java
Go to the documentation of this file.
1 /*
2  * Vortex OpenSplice
3  *
4  * This software and documentation are Copyright 2006 to 2021 ADLINK
5  * Technology Limited, its affiliated companies and licensors. All rights
6  * reserved.
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  *
20  */
21 package org.opensplice.dds.core.policy;
22 
26 
27 public class ResourceLimitsImpl extends QosPolicyImpl implements ResourceLimits {
28  private static final long serialVersionUID = 918915709322634268L;
29  private final int maxSamples;
30  private final int maxInstances;
31  private final int maxSamplesPerInstance;
32 
34  super(environment);
35  this.maxSamples = -1;
36  this.maxInstances = -1;
37  this.maxSamplesPerInstance = -1;
38  }
39 
41  int maxSamples, int maxInstances, int maxSamplesPerInstance) {
42  super(environment);
43  this.maxSamples = maxSamples;
44  this.maxInstances = maxInstances;
45  this.maxSamplesPerInstance = maxSamplesPerInstance;
46  }
47 
48  @Override
49  public int getMaxSamples() {
50  return this.maxSamples;
51  }
52 
53  @Override
54  public int getMaxInstances() {
55  return this.maxInstances;
56  }
57 
58  @Override
59  public int getMaxSamplesPerInstance() {
60  return this.maxSamplesPerInstance;
61  }
62 
63  @Override
64  public ResourceLimits withMaxSamples(int maxSamples) {
65  return new ResourceLimitsImpl(this.environment, maxSamples,
66  this.maxInstances, this.maxSamplesPerInstance);
67  }
68 
69  @Override
70  public ResourceLimits withMaxInstances(int maxInstances) {
71  return new ResourceLimitsImpl(this.environment, this.maxSamples,
72  maxInstances, this.maxSamplesPerInstance);
73  }
74 
75  @Override
76  public ResourceLimits withMaxSamplesPerInstance(int maxSamplesPerInstance) {
77  return new ResourceLimitsImpl(this.environment, this.maxSamples,
78  this.maxInstances, maxSamplesPerInstance);
79  }
80 
81  @Override
82  public Class<? extends QosPolicy> getPolicyClass() {
83  return ResourceLimits.class;
84  }
85 
86  @Override
87  public boolean equals(Object other) {
88  if (!(other instanceof ResourceLimitsImpl)) {
89  return false;
90  }
91  ResourceLimitsImpl r = (ResourceLimitsImpl) other;
92 
93  if (this.maxInstances != r.maxInstances) {
94  return false;
95  }
96  if (this.maxSamples != r.maxSamples) {
97  return false;
98  }
99  return (this.maxSamplesPerInstance == r.maxSamplesPerInstance);
100  }
101 
102  @Override
103  public int hashCode() {
104  final int prime = 31;
105  int result = 17;
106 
107  result = prime * result + this.maxInstances;
108  result = prime * result + this.maxSamples;
109 
110  return prime * result + this.maxSamplesPerInstance;
111  }
112 }
ResourceLimits withMaxInstances(int maxInstances)
Copy this policy and override the value of the property.
ResourceLimits withMaxSamplesPerInstance(int maxSamplesPerInstance)
Copy this policy and override the value of the property.
ResourceLimitsImpl(OsplServiceEnvironment environment)
ResourceLimits withMaxSamples(int maxSamples)
Copy this policy and override the value of the property.
This class is the abstract root for all the QoS policies.
Definition: QosPolicy.java:118
ResourceLimitsImpl(OsplServiceEnvironment environment, int maxSamples, int maxInstances, int maxSamplesPerInstance)
Specifies the resources that the Service can consume in order to meet the requested QoS...