proj_name
stringclasses 91
values | relative_path
stringclasses 558
values | class_name
stringclasses 959
values | func_name
stringlengths 1
70
| masked_class
stringlengths 69
162k
| func_body
stringlengths 0
30.5k
|
---|---|---|---|---|---|
Nepxion_Discovery | Discovery/discovery-commons/discovery-common/src/main/java/com/nepxion/discovery/common/entity/GatewayStrategyRouteEntity.java | GatewayStrategyRouteEntity | getId | class GatewayStrategyRouteEntity implements Serializable {
private static final long serialVersionUID = 8552414941889295450L;
private String id;
private String uri;
private List<String> predicates = new ArrayList<String>();
private List<Predicate> userPredicates = new ArrayList<Predicate>();
private List<String> filters = new ArrayList<String>();
private List<Filter> userFilters = new ArrayList<Filter>();
private int order = 0;
private Map<String, Object> metadata = new HashMap<String, Object>();
public String getId() {<FILL_FUNCTION_BODY>}
public void setId(String id) {
this.id = id;
}
public String getUri() {
return uri;
}
public void setUri(String uri) {
this.uri = uri;
}
public List<String> getPredicates() {
return predicates;
}
public void setPredicates(List<String> predicates) {
this.predicates = predicates;
}
public List<Predicate> getUserPredicates() {
return userPredicates;
}
public void setUserPredicates(List<Predicate> userPredicates) {
this.userPredicates = userPredicates;
}
public List<String> getFilters() {
return filters;
}
public void setFilters(List<String> filters) {
this.filters = filters;
}
public List<Filter> getUserFilters() {
return userFilters;
}
public void setUserFilters(List<Filter> userFilters) {
this.userFilters = userFilters;
}
public int getOrder() {
return order;
}
public void setOrder(int order) {
this.order = order;
}
public Map<String, Object> getMetadata() {
return metadata;
}
public void setMetadata(Map<String, Object> metadata) {
if (metadata != null) {
this.metadata = metadata;
}
}
public static class Predicate extends Clause {
private static final long serialVersionUID = -5113611207453059195L;
@Override
public int hashCode() {
return HashCodeBuilder.reflectionHashCode(this);
}
@Override
public boolean equals(Object object) {
return EqualsBuilder.reflectionEquals(this, object);
}
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
}
}
public static class Filter extends Clause {
private static final long serialVersionUID = 4975847305584873755L;
@Override
public int hashCode() {
return HashCodeBuilder.reflectionHashCode(this);
}
@Override
public boolean equals(Object object) {
return EqualsBuilder.reflectionEquals(this, object);
}
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
}
}
public static class Clause implements Serializable {
private static final long serialVersionUID = -6284675851623689077L;
private String name;
private Map<String, String> args = new LinkedHashMap<>();
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Map<String, String> getArgs() {
return args;
}
public void setArgs(Map<String, String> args) {
this.args = args;
}
public void addArg(String key, String value) {
this.args.put(key, value);
}
@Override
public int hashCode() {
return HashCodeBuilder.reflectionHashCode(this);
}
@Override
public boolean equals(Object object) {
return EqualsBuilder.reflectionEquals(this, object);
}
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
}
}
public static <T extends Clause> String toClausesJson(List<T> clauses) {
StringBuilder stringBuilder = new StringBuilder();
for (Clause clause : clauses) {
stringBuilder.append(String.format("%s=%s, ", clause.getName(), JsonUtil.toJson(clause.getArgs())));
}
if (stringBuilder.length() > 0) {
stringBuilder.delete(stringBuilder.length() - 2, stringBuilder.length());
}
return stringBuilder.toString();
}
@Override
public int hashCode() {
return HashCodeBuilder.reflectionHashCode(this);
}
@Override
public boolean equals(Object object) {
return EqualsBuilder.reflectionEquals(this, object);
}
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
}
} |
return id;
|
Nepxion_Discovery | Discovery/discovery-commons/discovery-common/src/main/java/com/nepxion/discovery/common/entity/GatewayStrategyRouteEntity.java | GatewayStrategyRouteEntity | setId | class GatewayStrategyRouteEntity implements Serializable {
private static final long serialVersionUID = 8552414941889295450L;
private String id;
private String uri;
private List<String> predicates = new ArrayList<String>();
private List<Predicate> userPredicates = new ArrayList<Predicate>();
private List<String> filters = new ArrayList<String>();
private List<Filter> userFilters = new ArrayList<Filter>();
private int order = 0;
private Map<String, Object> metadata = new HashMap<String, Object>();
public String getId() {
return id;
}
public void setId(String id) {<FILL_FUNCTION_BODY>}
public String getUri() {
return uri;
}
public void setUri(String uri) {
this.uri = uri;
}
public List<String> getPredicates() {
return predicates;
}
public void setPredicates(List<String> predicates) {
this.predicates = predicates;
}
public List<Predicate> getUserPredicates() {
return userPredicates;
}
public void setUserPredicates(List<Predicate> userPredicates) {
this.userPredicates = userPredicates;
}
public List<String> getFilters() {
return filters;
}
public void setFilters(List<String> filters) {
this.filters = filters;
}
public List<Filter> getUserFilters() {
return userFilters;
}
public void setUserFilters(List<Filter> userFilters) {
this.userFilters = userFilters;
}
public int getOrder() {
return order;
}
public void setOrder(int order) {
this.order = order;
}
public Map<String, Object> getMetadata() {
return metadata;
}
public void setMetadata(Map<String, Object> metadata) {
if (metadata != null) {
this.metadata = metadata;
}
}
public static class Predicate extends Clause {
private static final long serialVersionUID = -5113611207453059195L;
@Override
public int hashCode() {
return HashCodeBuilder.reflectionHashCode(this);
}
@Override
public boolean equals(Object object) {
return EqualsBuilder.reflectionEquals(this, object);
}
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
}
}
public static class Filter extends Clause {
private static final long serialVersionUID = 4975847305584873755L;
@Override
public int hashCode() {
return HashCodeBuilder.reflectionHashCode(this);
}
@Override
public boolean equals(Object object) {
return EqualsBuilder.reflectionEquals(this, object);
}
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
}
}
public static class Clause implements Serializable {
private static final long serialVersionUID = -6284675851623689077L;
private String name;
private Map<String, String> args = new LinkedHashMap<>();
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Map<String, String> getArgs() {
return args;
}
public void setArgs(Map<String, String> args) {
this.args = args;
}
public void addArg(String key, String value) {
this.args.put(key, value);
}
@Override
public int hashCode() {
return HashCodeBuilder.reflectionHashCode(this);
}
@Override
public boolean equals(Object object) {
return EqualsBuilder.reflectionEquals(this, object);
}
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
}
}
public static <T extends Clause> String toClausesJson(List<T> clauses) {
StringBuilder stringBuilder = new StringBuilder();
for (Clause clause : clauses) {
stringBuilder.append(String.format("%s=%s, ", clause.getName(), JsonUtil.toJson(clause.getArgs())));
}
if (stringBuilder.length() > 0) {
stringBuilder.delete(stringBuilder.length() - 2, stringBuilder.length());
}
return stringBuilder.toString();
}
@Override
public int hashCode() {
return HashCodeBuilder.reflectionHashCode(this);
}
@Override
public boolean equals(Object object) {
return EqualsBuilder.reflectionEquals(this, object);
}
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
}
} |
this.id = id;
|
Nepxion_Discovery | Discovery/discovery-commons/discovery-common/src/main/java/com/nepxion/discovery/common/entity/GatewayStrategyRouteEntity.java | GatewayStrategyRouteEntity | getUri | class GatewayStrategyRouteEntity implements Serializable {
private static final long serialVersionUID = 8552414941889295450L;
private String id;
private String uri;
private List<String> predicates = new ArrayList<String>();
private List<Predicate> userPredicates = new ArrayList<Predicate>();
private List<String> filters = new ArrayList<String>();
private List<Filter> userFilters = new ArrayList<Filter>();
private int order = 0;
private Map<String, Object> metadata = new HashMap<String, Object>();
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getUri() {<FILL_FUNCTION_BODY>}
public void setUri(String uri) {
this.uri = uri;
}
public List<String> getPredicates() {
return predicates;
}
public void setPredicates(List<String> predicates) {
this.predicates = predicates;
}
public List<Predicate> getUserPredicates() {
return userPredicates;
}
public void setUserPredicates(List<Predicate> userPredicates) {
this.userPredicates = userPredicates;
}
public List<String> getFilters() {
return filters;
}
public void setFilters(List<String> filters) {
this.filters = filters;
}
public List<Filter> getUserFilters() {
return userFilters;
}
public void setUserFilters(List<Filter> userFilters) {
this.userFilters = userFilters;
}
public int getOrder() {
return order;
}
public void setOrder(int order) {
this.order = order;
}
public Map<String, Object> getMetadata() {
return metadata;
}
public void setMetadata(Map<String, Object> metadata) {
if (metadata != null) {
this.metadata = metadata;
}
}
public static class Predicate extends Clause {
private static final long serialVersionUID = -5113611207453059195L;
@Override
public int hashCode() {
return HashCodeBuilder.reflectionHashCode(this);
}
@Override
public boolean equals(Object object) {
return EqualsBuilder.reflectionEquals(this, object);
}
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
}
}
public static class Filter extends Clause {
private static final long serialVersionUID = 4975847305584873755L;
@Override
public int hashCode() {
return HashCodeBuilder.reflectionHashCode(this);
}
@Override
public boolean equals(Object object) {
return EqualsBuilder.reflectionEquals(this, object);
}
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
}
}
public static class Clause implements Serializable {
private static final long serialVersionUID = -6284675851623689077L;
private String name;
private Map<String, String> args = new LinkedHashMap<>();
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Map<String, String> getArgs() {
return args;
}
public void setArgs(Map<String, String> args) {
this.args = args;
}
public void addArg(String key, String value) {
this.args.put(key, value);
}
@Override
public int hashCode() {
return HashCodeBuilder.reflectionHashCode(this);
}
@Override
public boolean equals(Object object) {
return EqualsBuilder.reflectionEquals(this, object);
}
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
}
}
public static <T extends Clause> String toClausesJson(List<T> clauses) {
StringBuilder stringBuilder = new StringBuilder();
for (Clause clause : clauses) {
stringBuilder.append(String.format("%s=%s, ", clause.getName(), JsonUtil.toJson(clause.getArgs())));
}
if (stringBuilder.length() > 0) {
stringBuilder.delete(stringBuilder.length() - 2, stringBuilder.length());
}
return stringBuilder.toString();
}
@Override
public int hashCode() {
return HashCodeBuilder.reflectionHashCode(this);
}
@Override
public boolean equals(Object object) {
return EqualsBuilder.reflectionEquals(this, object);
}
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
}
} |
return uri;
|
Nepxion_Discovery | Discovery/discovery-commons/discovery-common/src/main/java/com/nepxion/discovery/common/entity/GatewayStrategyRouteEntity.java | GatewayStrategyRouteEntity | setUri | class GatewayStrategyRouteEntity implements Serializable {
private static final long serialVersionUID = 8552414941889295450L;
private String id;
private String uri;
private List<String> predicates = new ArrayList<String>();
private List<Predicate> userPredicates = new ArrayList<Predicate>();
private List<String> filters = new ArrayList<String>();
private List<Filter> userFilters = new ArrayList<Filter>();
private int order = 0;
private Map<String, Object> metadata = new HashMap<String, Object>();
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getUri() {
return uri;
}
public void setUri(String uri) {<FILL_FUNCTION_BODY>}
public List<String> getPredicates() {
return predicates;
}
public void setPredicates(List<String> predicates) {
this.predicates = predicates;
}
public List<Predicate> getUserPredicates() {
return userPredicates;
}
public void setUserPredicates(List<Predicate> userPredicates) {
this.userPredicates = userPredicates;
}
public List<String> getFilters() {
return filters;
}
public void setFilters(List<String> filters) {
this.filters = filters;
}
public List<Filter> getUserFilters() {
return userFilters;
}
public void setUserFilters(List<Filter> userFilters) {
this.userFilters = userFilters;
}
public int getOrder() {
return order;
}
public void setOrder(int order) {
this.order = order;
}
public Map<String, Object> getMetadata() {
return metadata;
}
public void setMetadata(Map<String, Object> metadata) {
if (metadata != null) {
this.metadata = metadata;
}
}
public static class Predicate extends Clause {
private static final long serialVersionUID = -5113611207453059195L;
@Override
public int hashCode() {
return HashCodeBuilder.reflectionHashCode(this);
}
@Override
public boolean equals(Object object) {
return EqualsBuilder.reflectionEquals(this, object);
}
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
}
}
public static class Filter extends Clause {
private static final long serialVersionUID = 4975847305584873755L;
@Override
public int hashCode() {
return HashCodeBuilder.reflectionHashCode(this);
}
@Override
public boolean equals(Object object) {
return EqualsBuilder.reflectionEquals(this, object);
}
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
}
}
public static class Clause implements Serializable {
private static final long serialVersionUID = -6284675851623689077L;
private String name;
private Map<String, String> args = new LinkedHashMap<>();
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Map<String, String> getArgs() {
return args;
}
public void setArgs(Map<String, String> args) {
this.args = args;
}
public void addArg(String key, String value) {
this.args.put(key, value);
}
@Override
public int hashCode() {
return HashCodeBuilder.reflectionHashCode(this);
}
@Override
public boolean equals(Object object) {
return EqualsBuilder.reflectionEquals(this, object);
}
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
}
}
public static <T extends Clause> String toClausesJson(List<T> clauses) {
StringBuilder stringBuilder = new StringBuilder();
for (Clause clause : clauses) {
stringBuilder.append(String.format("%s=%s, ", clause.getName(), JsonUtil.toJson(clause.getArgs())));
}
if (stringBuilder.length() > 0) {
stringBuilder.delete(stringBuilder.length() - 2, stringBuilder.length());
}
return stringBuilder.toString();
}
@Override
public int hashCode() {
return HashCodeBuilder.reflectionHashCode(this);
}
@Override
public boolean equals(Object object) {
return EqualsBuilder.reflectionEquals(this, object);
}
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
}
} |
this.uri = uri;
|
Nepxion_Discovery | Discovery/discovery-commons/discovery-common/src/main/java/com/nepxion/discovery/common/entity/GatewayStrategyRouteEntity.java | GatewayStrategyRouteEntity | getPredicates | class GatewayStrategyRouteEntity implements Serializable {
private static final long serialVersionUID = 8552414941889295450L;
private String id;
private String uri;
private List<String> predicates = new ArrayList<String>();
private List<Predicate> userPredicates = new ArrayList<Predicate>();
private List<String> filters = new ArrayList<String>();
private List<Filter> userFilters = new ArrayList<Filter>();
private int order = 0;
private Map<String, Object> metadata = new HashMap<String, Object>();
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getUri() {
return uri;
}
public void setUri(String uri) {
this.uri = uri;
}
public List<String> getPredicates() {<FILL_FUNCTION_BODY>}
public void setPredicates(List<String> predicates) {
this.predicates = predicates;
}
public List<Predicate> getUserPredicates() {
return userPredicates;
}
public void setUserPredicates(List<Predicate> userPredicates) {
this.userPredicates = userPredicates;
}
public List<String> getFilters() {
return filters;
}
public void setFilters(List<String> filters) {
this.filters = filters;
}
public List<Filter> getUserFilters() {
return userFilters;
}
public void setUserFilters(List<Filter> userFilters) {
this.userFilters = userFilters;
}
public int getOrder() {
return order;
}
public void setOrder(int order) {
this.order = order;
}
public Map<String, Object> getMetadata() {
return metadata;
}
public void setMetadata(Map<String, Object> metadata) {
if (metadata != null) {
this.metadata = metadata;
}
}
public static class Predicate extends Clause {
private static final long serialVersionUID = -5113611207453059195L;
@Override
public int hashCode() {
return HashCodeBuilder.reflectionHashCode(this);
}
@Override
public boolean equals(Object object) {
return EqualsBuilder.reflectionEquals(this, object);
}
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
}
}
public static class Filter extends Clause {
private static final long serialVersionUID = 4975847305584873755L;
@Override
public int hashCode() {
return HashCodeBuilder.reflectionHashCode(this);
}
@Override
public boolean equals(Object object) {
return EqualsBuilder.reflectionEquals(this, object);
}
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
}
}
public static class Clause implements Serializable {
private static final long serialVersionUID = -6284675851623689077L;
private String name;
private Map<String, String> args = new LinkedHashMap<>();
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Map<String, String> getArgs() {
return args;
}
public void setArgs(Map<String, String> args) {
this.args = args;
}
public void addArg(String key, String value) {
this.args.put(key, value);
}
@Override
public int hashCode() {
return HashCodeBuilder.reflectionHashCode(this);
}
@Override
public boolean equals(Object object) {
return EqualsBuilder.reflectionEquals(this, object);
}
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
}
}
public static <T extends Clause> String toClausesJson(List<T> clauses) {
StringBuilder stringBuilder = new StringBuilder();
for (Clause clause : clauses) {
stringBuilder.append(String.format("%s=%s, ", clause.getName(), JsonUtil.toJson(clause.getArgs())));
}
if (stringBuilder.length() > 0) {
stringBuilder.delete(stringBuilder.length() - 2, stringBuilder.length());
}
return stringBuilder.toString();
}
@Override
public int hashCode() {
return HashCodeBuilder.reflectionHashCode(this);
}
@Override
public boolean equals(Object object) {
return EqualsBuilder.reflectionEquals(this, object);
}
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
}
} |
return predicates;
|
Nepxion_Discovery | Discovery/discovery-commons/discovery-common/src/main/java/com/nepxion/discovery/common/entity/GatewayStrategyRouteEntity.java | GatewayStrategyRouteEntity | setPredicates | class GatewayStrategyRouteEntity implements Serializable {
private static final long serialVersionUID = 8552414941889295450L;
private String id;
private String uri;
private List<String> predicates = new ArrayList<String>();
private List<Predicate> userPredicates = new ArrayList<Predicate>();
private List<String> filters = new ArrayList<String>();
private List<Filter> userFilters = new ArrayList<Filter>();
private int order = 0;
private Map<String, Object> metadata = new HashMap<String, Object>();
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getUri() {
return uri;
}
public void setUri(String uri) {
this.uri = uri;
}
public List<String> getPredicates() {
return predicates;
}
public void setPredicates(List<String> predicates) {<FILL_FUNCTION_BODY>}
public List<Predicate> getUserPredicates() {
return userPredicates;
}
public void setUserPredicates(List<Predicate> userPredicates) {
this.userPredicates = userPredicates;
}
public List<String> getFilters() {
return filters;
}
public void setFilters(List<String> filters) {
this.filters = filters;
}
public List<Filter> getUserFilters() {
return userFilters;
}
public void setUserFilters(List<Filter> userFilters) {
this.userFilters = userFilters;
}
public int getOrder() {
return order;
}
public void setOrder(int order) {
this.order = order;
}
public Map<String, Object> getMetadata() {
return metadata;
}
public void setMetadata(Map<String, Object> metadata) {
if (metadata != null) {
this.metadata = metadata;
}
}
public static class Predicate extends Clause {
private static final long serialVersionUID = -5113611207453059195L;
@Override
public int hashCode() {
return HashCodeBuilder.reflectionHashCode(this);
}
@Override
public boolean equals(Object object) {
return EqualsBuilder.reflectionEquals(this, object);
}
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
}
}
public static class Filter extends Clause {
private static final long serialVersionUID = 4975847305584873755L;
@Override
public int hashCode() {
return HashCodeBuilder.reflectionHashCode(this);
}
@Override
public boolean equals(Object object) {
return EqualsBuilder.reflectionEquals(this, object);
}
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
}
}
public static class Clause implements Serializable {
private static final long serialVersionUID = -6284675851623689077L;
private String name;
private Map<String, String> args = new LinkedHashMap<>();
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Map<String, String> getArgs() {
return args;
}
public void setArgs(Map<String, String> args) {
this.args = args;
}
public void addArg(String key, String value) {
this.args.put(key, value);
}
@Override
public int hashCode() {
return HashCodeBuilder.reflectionHashCode(this);
}
@Override
public boolean equals(Object object) {
return EqualsBuilder.reflectionEquals(this, object);
}
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
}
}
public static <T extends Clause> String toClausesJson(List<T> clauses) {
StringBuilder stringBuilder = new StringBuilder();
for (Clause clause : clauses) {
stringBuilder.append(String.format("%s=%s, ", clause.getName(), JsonUtil.toJson(clause.getArgs())));
}
if (stringBuilder.length() > 0) {
stringBuilder.delete(stringBuilder.length() - 2, stringBuilder.length());
}
return stringBuilder.toString();
}
@Override
public int hashCode() {
return HashCodeBuilder.reflectionHashCode(this);
}
@Override
public boolean equals(Object object) {
return EqualsBuilder.reflectionEquals(this, object);
}
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
}
} |
this.predicates = predicates;
|
Nepxion_Discovery | Discovery/discovery-commons/discovery-common/src/main/java/com/nepxion/discovery/common/entity/GatewayStrategyRouteEntity.java | GatewayStrategyRouteEntity | getUserPredicates | class GatewayStrategyRouteEntity implements Serializable {
private static final long serialVersionUID = 8552414941889295450L;
private String id;
private String uri;
private List<String> predicates = new ArrayList<String>();
private List<Predicate> userPredicates = new ArrayList<Predicate>();
private List<String> filters = new ArrayList<String>();
private List<Filter> userFilters = new ArrayList<Filter>();
private int order = 0;
private Map<String, Object> metadata = new HashMap<String, Object>();
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getUri() {
return uri;
}
public void setUri(String uri) {
this.uri = uri;
}
public List<String> getPredicates() {
return predicates;
}
public void setPredicates(List<String> predicates) {
this.predicates = predicates;
}
public List<Predicate> getUserPredicates() {<FILL_FUNCTION_BODY>}
public void setUserPredicates(List<Predicate> userPredicates) {
this.userPredicates = userPredicates;
}
public List<String> getFilters() {
return filters;
}
public void setFilters(List<String> filters) {
this.filters = filters;
}
public List<Filter> getUserFilters() {
return userFilters;
}
public void setUserFilters(List<Filter> userFilters) {
this.userFilters = userFilters;
}
public int getOrder() {
return order;
}
public void setOrder(int order) {
this.order = order;
}
public Map<String, Object> getMetadata() {
return metadata;
}
public void setMetadata(Map<String, Object> metadata) {
if (metadata != null) {
this.metadata = metadata;
}
}
public static class Predicate extends Clause {
private static final long serialVersionUID = -5113611207453059195L;
@Override
public int hashCode() {
return HashCodeBuilder.reflectionHashCode(this);
}
@Override
public boolean equals(Object object) {
return EqualsBuilder.reflectionEquals(this, object);
}
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
}
}
public static class Filter extends Clause {
private static final long serialVersionUID = 4975847305584873755L;
@Override
public int hashCode() {
return HashCodeBuilder.reflectionHashCode(this);
}
@Override
public boolean equals(Object object) {
return EqualsBuilder.reflectionEquals(this, object);
}
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
}
}
public static class Clause implements Serializable {
private static final long serialVersionUID = -6284675851623689077L;
private String name;
private Map<String, String> args = new LinkedHashMap<>();
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Map<String, String> getArgs() {
return args;
}
public void setArgs(Map<String, String> args) {
this.args = args;
}
public void addArg(String key, String value) {
this.args.put(key, value);
}
@Override
public int hashCode() {
return HashCodeBuilder.reflectionHashCode(this);
}
@Override
public boolean equals(Object object) {
return EqualsBuilder.reflectionEquals(this, object);
}
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
}
}
public static <T extends Clause> String toClausesJson(List<T> clauses) {
StringBuilder stringBuilder = new StringBuilder();
for (Clause clause : clauses) {
stringBuilder.append(String.format("%s=%s, ", clause.getName(), JsonUtil.toJson(clause.getArgs())));
}
if (stringBuilder.length() > 0) {
stringBuilder.delete(stringBuilder.length() - 2, stringBuilder.length());
}
return stringBuilder.toString();
}
@Override
public int hashCode() {
return HashCodeBuilder.reflectionHashCode(this);
}
@Override
public boolean equals(Object object) {
return EqualsBuilder.reflectionEquals(this, object);
}
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
}
} |
return userPredicates;
|
Nepxion_Discovery | Discovery/discovery-commons/discovery-common/src/main/java/com/nepxion/discovery/common/entity/GatewayStrategyRouteEntity.java | GatewayStrategyRouteEntity | setUserPredicates | class GatewayStrategyRouteEntity implements Serializable {
private static final long serialVersionUID = 8552414941889295450L;
private String id;
private String uri;
private List<String> predicates = new ArrayList<String>();
private List<Predicate> userPredicates = new ArrayList<Predicate>();
private List<String> filters = new ArrayList<String>();
private List<Filter> userFilters = new ArrayList<Filter>();
private int order = 0;
private Map<String, Object> metadata = new HashMap<String, Object>();
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getUri() {
return uri;
}
public void setUri(String uri) {
this.uri = uri;
}
public List<String> getPredicates() {
return predicates;
}
public void setPredicates(List<String> predicates) {
this.predicates = predicates;
}
public List<Predicate> getUserPredicates() {
return userPredicates;
}
public void setUserPredicates(List<Predicate> userPredicates) {<FILL_FUNCTION_BODY>}
public List<String> getFilters() {
return filters;
}
public void setFilters(List<String> filters) {
this.filters = filters;
}
public List<Filter> getUserFilters() {
return userFilters;
}
public void setUserFilters(List<Filter> userFilters) {
this.userFilters = userFilters;
}
public int getOrder() {
return order;
}
public void setOrder(int order) {
this.order = order;
}
public Map<String, Object> getMetadata() {
return metadata;
}
public void setMetadata(Map<String, Object> metadata) {
if (metadata != null) {
this.metadata = metadata;
}
}
public static class Predicate extends Clause {
private static final long serialVersionUID = -5113611207453059195L;
@Override
public int hashCode() {
return HashCodeBuilder.reflectionHashCode(this);
}
@Override
public boolean equals(Object object) {
return EqualsBuilder.reflectionEquals(this, object);
}
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
}
}
public static class Filter extends Clause {
private static final long serialVersionUID = 4975847305584873755L;
@Override
public int hashCode() {
return HashCodeBuilder.reflectionHashCode(this);
}
@Override
public boolean equals(Object object) {
return EqualsBuilder.reflectionEquals(this, object);
}
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
}
}
public static class Clause implements Serializable {
private static final long serialVersionUID = -6284675851623689077L;
private String name;
private Map<String, String> args = new LinkedHashMap<>();
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Map<String, String> getArgs() {
return args;
}
public void setArgs(Map<String, String> args) {
this.args = args;
}
public void addArg(String key, String value) {
this.args.put(key, value);
}
@Override
public int hashCode() {
return HashCodeBuilder.reflectionHashCode(this);
}
@Override
public boolean equals(Object object) {
return EqualsBuilder.reflectionEquals(this, object);
}
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
}
}
public static <T extends Clause> String toClausesJson(List<T> clauses) {
StringBuilder stringBuilder = new StringBuilder();
for (Clause clause : clauses) {
stringBuilder.append(String.format("%s=%s, ", clause.getName(), JsonUtil.toJson(clause.getArgs())));
}
if (stringBuilder.length() > 0) {
stringBuilder.delete(stringBuilder.length() - 2, stringBuilder.length());
}
return stringBuilder.toString();
}
@Override
public int hashCode() {
return HashCodeBuilder.reflectionHashCode(this);
}
@Override
public boolean equals(Object object) {
return EqualsBuilder.reflectionEquals(this, object);
}
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
}
} |
this.userPredicates = userPredicates;
|
Nepxion_Discovery | Discovery/discovery-commons/discovery-common/src/main/java/com/nepxion/discovery/common/entity/GatewayStrategyRouteEntity.java | GatewayStrategyRouteEntity | getFilters | class GatewayStrategyRouteEntity implements Serializable {
private static final long serialVersionUID = 8552414941889295450L;
private String id;
private String uri;
private List<String> predicates = new ArrayList<String>();
private List<Predicate> userPredicates = new ArrayList<Predicate>();
private List<String> filters = new ArrayList<String>();
private List<Filter> userFilters = new ArrayList<Filter>();
private int order = 0;
private Map<String, Object> metadata = new HashMap<String, Object>();
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getUri() {
return uri;
}
public void setUri(String uri) {
this.uri = uri;
}
public List<String> getPredicates() {
return predicates;
}
public void setPredicates(List<String> predicates) {
this.predicates = predicates;
}
public List<Predicate> getUserPredicates() {
return userPredicates;
}
public void setUserPredicates(List<Predicate> userPredicates) {
this.userPredicates = userPredicates;
}
public List<String> getFilters() {<FILL_FUNCTION_BODY>}
public void setFilters(List<String> filters) {
this.filters = filters;
}
public List<Filter> getUserFilters() {
return userFilters;
}
public void setUserFilters(List<Filter> userFilters) {
this.userFilters = userFilters;
}
public int getOrder() {
return order;
}
public void setOrder(int order) {
this.order = order;
}
public Map<String, Object> getMetadata() {
return metadata;
}
public void setMetadata(Map<String, Object> metadata) {
if (metadata != null) {
this.metadata = metadata;
}
}
public static class Predicate extends Clause {
private static final long serialVersionUID = -5113611207453059195L;
@Override
public int hashCode() {
return HashCodeBuilder.reflectionHashCode(this);
}
@Override
public boolean equals(Object object) {
return EqualsBuilder.reflectionEquals(this, object);
}
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
}
}
public static class Filter extends Clause {
private static final long serialVersionUID = 4975847305584873755L;
@Override
public int hashCode() {
return HashCodeBuilder.reflectionHashCode(this);
}
@Override
public boolean equals(Object object) {
return EqualsBuilder.reflectionEquals(this, object);
}
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
}
}
public static class Clause implements Serializable {
private static final long serialVersionUID = -6284675851623689077L;
private String name;
private Map<String, String> args = new LinkedHashMap<>();
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Map<String, String> getArgs() {
return args;
}
public void setArgs(Map<String, String> args) {
this.args = args;
}
public void addArg(String key, String value) {
this.args.put(key, value);
}
@Override
public int hashCode() {
return HashCodeBuilder.reflectionHashCode(this);
}
@Override
public boolean equals(Object object) {
return EqualsBuilder.reflectionEquals(this, object);
}
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
}
}
public static <T extends Clause> String toClausesJson(List<T> clauses) {
StringBuilder stringBuilder = new StringBuilder();
for (Clause clause : clauses) {
stringBuilder.append(String.format("%s=%s, ", clause.getName(), JsonUtil.toJson(clause.getArgs())));
}
if (stringBuilder.length() > 0) {
stringBuilder.delete(stringBuilder.length() - 2, stringBuilder.length());
}
return stringBuilder.toString();
}
@Override
public int hashCode() {
return HashCodeBuilder.reflectionHashCode(this);
}
@Override
public boolean equals(Object object) {
return EqualsBuilder.reflectionEquals(this, object);
}
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
}
} |
return filters;
|
Nepxion_Discovery | Discovery/discovery-commons/discovery-common/src/main/java/com/nepxion/discovery/common/entity/GatewayStrategyRouteEntity.java | GatewayStrategyRouteEntity | setFilters | class GatewayStrategyRouteEntity implements Serializable {
private static final long serialVersionUID = 8552414941889295450L;
private String id;
private String uri;
private List<String> predicates = new ArrayList<String>();
private List<Predicate> userPredicates = new ArrayList<Predicate>();
private List<String> filters = new ArrayList<String>();
private List<Filter> userFilters = new ArrayList<Filter>();
private int order = 0;
private Map<String, Object> metadata = new HashMap<String, Object>();
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getUri() {
return uri;
}
public void setUri(String uri) {
this.uri = uri;
}
public List<String> getPredicates() {
return predicates;
}
public void setPredicates(List<String> predicates) {
this.predicates = predicates;
}
public List<Predicate> getUserPredicates() {
return userPredicates;
}
public void setUserPredicates(List<Predicate> userPredicates) {
this.userPredicates = userPredicates;
}
public List<String> getFilters() {
return filters;
}
public void setFilters(List<String> filters) {<FILL_FUNCTION_BODY>}
public List<Filter> getUserFilters() {
return userFilters;
}
public void setUserFilters(List<Filter> userFilters) {
this.userFilters = userFilters;
}
public int getOrder() {
return order;
}
public void setOrder(int order) {
this.order = order;
}
public Map<String, Object> getMetadata() {
return metadata;
}
public void setMetadata(Map<String, Object> metadata) {
if (metadata != null) {
this.metadata = metadata;
}
}
public static class Predicate extends Clause {
private static final long serialVersionUID = -5113611207453059195L;
@Override
public int hashCode() {
return HashCodeBuilder.reflectionHashCode(this);
}
@Override
public boolean equals(Object object) {
return EqualsBuilder.reflectionEquals(this, object);
}
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
}
}
public static class Filter extends Clause {
private static final long serialVersionUID = 4975847305584873755L;
@Override
public int hashCode() {
return HashCodeBuilder.reflectionHashCode(this);
}
@Override
public boolean equals(Object object) {
return EqualsBuilder.reflectionEquals(this, object);
}
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
}
}
public static class Clause implements Serializable {
private static final long serialVersionUID = -6284675851623689077L;
private String name;
private Map<String, String> args = new LinkedHashMap<>();
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Map<String, String> getArgs() {
return args;
}
public void setArgs(Map<String, String> args) {
this.args = args;
}
public void addArg(String key, String value) {
this.args.put(key, value);
}
@Override
public int hashCode() {
return HashCodeBuilder.reflectionHashCode(this);
}
@Override
public boolean equals(Object object) {
return EqualsBuilder.reflectionEquals(this, object);
}
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
}
}
public static <T extends Clause> String toClausesJson(List<T> clauses) {
StringBuilder stringBuilder = new StringBuilder();
for (Clause clause : clauses) {
stringBuilder.append(String.format("%s=%s, ", clause.getName(), JsonUtil.toJson(clause.getArgs())));
}
if (stringBuilder.length() > 0) {
stringBuilder.delete(stringBuilder.length() - 2, stringBuilder.length());
}
return stringBuilder.toString();
}
@Override
public int hashCode() {
return HashCodeBuilder.reflectionHashCode(this);
}
@Override
public boolean equals(Object object) {
return EqualsBuilder.reflectionEquals(this, object);
}
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
}
} |
this.filters = filters;
|
Nepxion_Discovery | Discovery/discovery-commons/discovery-common/src/main/java/com/nepxion/discovery/common/entity/GatewayStrategyRouteEntity.java | GatewayStrategyRouteEntity | getUserFilters | class GatewayStrategyRouteEntity implements Serializable {
private static final long serialVersionUID = 8552414941889295450L;
private String id;
private String uri;
private List<String> predicates = new ArrayList<String>();
private List<Predicate> userPredicates = new ArrayList<Predicate>();
private List<String> filters = new ArrayList<String>();
private List<Filter> userFilters = new ArrayList<Filter>();
private int order = 0;
private Map<String, Object> metadata = new HashMap<String, Object>();
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getUri() {
return uri;
}
public void setUri(String uri) {
this.uri = uri;
}
public List<String> getPredicates() {
return predicates;
}
public void setPredicates(List<String> predicates) {
this.predicates = predicates;
}
public List<Predicate> getUserPredicates() {
return userPredicates;
}
public void setUserPredicates(List<Predicate> userPredicates) {
this.userPredicates = userPredicates;
}
public List<String> getFilters() {
return filters;
}
public void setFilters(List<String> filters) {
this.filters = filters;
}
public List<Filter> getUserFilters() {<FILL_FUNCTION_BODY>}
public void setUserFilters(List<Filter> userFilters) {
this.userFilters = userFilters;
}
public int getOrder() {
return order;
}
public void setOrder(int order) {
this.order = order;
}
public Map<String, Object> getMetadata() {
return metadata;
}
public void setMetadata(Map<String, Object> metadata) {
if (metadata != null) {
this.metadata = metadata;
}
}
public static class Predicate extends Clause {
private static final long serialVersionUID = -5113611207453059195L;
@Override
public int hashCode() {
return HashCodeBuilder.reflectionHashCode(this);
}
@Override
public boolean equals(Object object) {
return EqualsBuilder.reflectionEquals(this, object);
}
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
}
}
public static class Filter extends Clause {
private static final long serialVersionUID = 4975847305584873755L;
@Override
public int hashCode() {
return HashCodeBuilder.reflectionHashCode(this);
}
@Override
public boolean equals(Object object) {
return EqualsBuilder.reflectionEquals(this, object);
}
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
}
}
public static class Clause implements Serializable {
private static final long serialVersionUID = -6284675851623689077L;
private String name;
private Map<String, String> args = new LinkedHashMap<>();
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Map<String, String> getArgs() {
return args;
}
public void setArgs(Map<String, String> args) {
this.args = args;
}
public void addArg(String key, String value) {
this.args.put(key, value);
}
@Override
public int hashCode() {
return HashCodeBuilder.reflectionHashCode(this);
}
@Override
public boolean equals(Object object) {
return EqualsBuilder.reflectionEquals(this, object);
}
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
}
}
public static <T extends Clause> String toClausesJson(List<T> clauses) {
StringBuilder stringBuilder = new StringBuilder();
for (Clause clause : clauses) {
stringBuilder.append(String.format("%s=%s, ", clause.getName(), JsonUtil.toJson(clause.getArgs())));
}
if (stringBuilder.length() > 0) {
stringBuilder.delete(stringBuilder.length() - 2, stringBuilder.length());
}
return stringBuilder.toString();
}
@Override
public int hashCode() {
return HashCodeBuilder.reflectionHashCode(this);
}
@Override
public boolean equals(Object object) {
return EqualsBuilder.reflectionEquals(this, object);
}
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
}
} |
return userFilters;
|
Nepxion_Discovery | Discovery/discovery-commons/discovery-common/src/main/java/com/nepxion/discovery/common/entity/GatewayStrategyRouteEntity.java | GatewayStrategyRouteEntity | setUserFilters | class GatewayStrategyRouteEntity implements Serializable {
private static final long serialVersionUID = 8552414941889295450L;
private String id;
private String uri;
private List<String> predicates = new ArrayList<String>();
private List<Predicate> userPredicates = new ArrayList<Predicate>();
private List<String> filters = new ArrayList<String>();
private List<Filter> userFilters = new ArrayList<Filter>();
private int order = 0;
private Map<String, Object> metadata = new HashMap<String, Object>();
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getUri() {
return uri;
}
public void setUri(String uri) {
this.uri = uri;
}
public List<String> getPredicates() {
return predicates;
}
public void setPredicates(List<String> predicates) {
this.predicates = predicates;
}
public List<Predicate> getUserPredicates() {
return userPredicates;
}
public void setUserPredicates(List<Predicate> userPredicates) {
this.userPredicates = userPredicates;
}
public List<String> getFilters() {
return filters;
}
public void setFilters(List<String> filters) {
this.filters = filters;
}
public List<Filter> getUserFilters() {
return userFilters;
}
public void setUserFilters(List<Filter> userFilters) {<FILL_FUNCTION_BODY>}
public int getOrder() {
return order;
}
public void setOrder(int order) {
this.order = order;
}
public Map<String, Object> getMetadata() {
return metadata;
}
public void setMetadata(Map<String, Object> metadata) {
if (metadata != null) {
this.metadata = metadata;
}
}
public static class Predicate extends Clause {
private static final long serialVersionUID = -5113611207453059195L;
@Override
public int hashCode() {
return HashCodeBuilder.reflectionHashCode(this);
}
@Override
public boolean equals(Object object) {
return EqualsBuilder.reflectionEquals(this, object);
}
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
}
}
public static class Filter extends Clause {
private static final long serialVersionUID = 4975847305584873755L;
@Override
public int hashCode() {
return HashCodeBuilder.reflectionHashCode(this);
}
@Override
public boolean equals(Object object) {
return EqualsBuilder.reflectionEquals(this, object);
}
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
}
}
public static class Clause implements Serializable {
private static final long serialVersionUID = -6284675851623689077L;
private String name;
private Map<String, String> args = new LinkedHashMap<>();
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Map<String, String> getArgs() {
return args;
}
public void setArgs(Map<String, String> args) {
this.args = args;
}
public void addArg(String key, String value) {
this.args.put(key, value);
}
@Override
public int hashCode() {
return HashCodeBuilder.reflectionHashCode(this);
}
@Override
public boolean equals(Object object) {
return EqualsBuilder.reflectionEquals(this, object);
}
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
}
}
public static <T extends Clause> String toClausesJson(List<T> clauses) {
StringBuilder stringBuilder = new StringBuilder();
for (Clause clause : clauses) {
stringBuilder.append(String.format("%s=%s, ", clause.getName(), JsonUtil.toJson(clause.getArgs())));
}
if (stringBuilder.length() > 0) {
stringBuilder.delete(stringBuilder.length() - 2, stringBuilder.length());
}
return stringBuilder.toString();
}
@Override
public int hashCode() {
return HashCodeBuilder.reflectionHashCode(this);
}
@Override
public boolean equals(Object object) {
return EqualsBuilder.reflectionEquals(this, object);
}
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
}
} |
this.userFilters = userFilters;
|
Nepxion_Discovery | Discovery/discovery-commons/discovery-common/src/main/java/com/nepxion/discovery/common/entity/GatewayStrategyRouteEntity.java | GatewayStrategyRouteEntity | getOrder | class GatewayStrategyRouteEntity implements Serializable {
private static final long serialVersionUID = 8552414941889295450L;
private String id;
private String uri;
private List<String> predicates = new ArrayList<String>();
private List<Predicate> userPredicates = new ArrayList<Predicate>();
private List<String> filters = new ArrayList<String>();
private List<Filter> userFilters = new ArrayList<Filter>();
private int order = 0;
private Map<String, Object> metadata = new HashMap<String, Object>();
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getUri() {
return uri;
}
public void setUri(String uri) {
this.uri = uri;
}
public List<String> getPredicates() {
return predicates;
}
public void setPredicates(List<String> predicates) {
this.predicates = predicates;
}
public List<Predicate> getUserPredicates() {
return userPredicates;
}
public void setUserPredicates(List<Predicate> userPredicates) {
this.userPredicates = userPredicates;
}
public List<String> getFilters() {
return filters;
}
public void setFilters(List<String> filters) {
this.filters = filters;
}
public List<Filter> getUserFilters() {
return userFilters;
}
public void setUserFilters(List<Filter> userFilters) {
this.userFilters = userFilters;
}
public int getOrder() {<FILL_FUNCTION_BODY>}
public void setOrder(int order) {
this.order = order;
}
public Map<String, Object> getMetadata() {
return metadata;
}
public void setMetadata(Map<String, Object> metadata) {
if (metadata != null) {
this.metadata = metadata;
}
}
public static class Predicate extends Clause {
private static final long serialVersionUID = -5113611207453059195L;
@Override
public int hashCode() {
return HashCodeBuilder.reflectionHashCode(this);
}
@Override
public boolean equals(Object object) {
return EqualsBuilder.reflectionEquals(this, object);
}
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
}
}
public static class Filter extends Clause {
private static final long serialVersionUID = 4975847305584873755L;
@Override
public int hashCode() {
return HashCodeBuilder.reflectionHashCode(this);
}
@Override
public boolean equals(Object object) {
return EqualsBuilder.reflectionEquals(this, object);
}
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
}
}
public static class Clause implements Serializable {
private static final long serialVersionUID = -6284675851623689077L;
private String name;
private Map<String, String> args = new LinkedHashMap<>();
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Map<String, String> getArgs() {
return args;
}
public void setArgs(Map<String, String> args) {
this.args = args;
}
public void addArg(String key, String value) {
this.args.put(key, value);
}
@Override
public int hashCode() {
return HashCodeBuilder.reflectionHashCode(this);
}
@Override
public boolean equals(Object object) {
return EqualsBuilder.reflectionEquals(this, object);
}
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
}
}
public static <T extends Clause> String toClausesJson(List<T> clauses) {
StringBuilder stringBuilder = new StringBuilder();
for (Clause clause : clauses) {
stringBuilder.append(String.format("%s=%s, ", clause.getName(), JsonUtil.toJson(clause.getArgs())));
}
if (stringBuilder.length() > 0) {
stringBuilder.delete(stringBuilder.length() - 2, stringBuilder.length());
}
return stringBuilder.toString();
}
@Override
public int hashCode() {
return HashCodeBuilder.reflectionHashCode(this);
}
@Override
public boolean equals(Object object) {
return EqualsBuilder.reflectionEquals(this, object);
}
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
}
} |
return order;
|
Nepxion_Discovery | Discovery/discovery-commons/discovery-common/src/main/java/com/nepxion/discovery/common/entity/GatewayStrategyRouteEntity.java | GatewayStrategyRouteEntity | setOrder | class GatewayStrategyRouteEntity implements Serializable {
private static final long serialVersionUID = 8552414941889295450L;
private String id;
private String uri;
private List<String> predicates = new ArrayList<String>();
private List<Predicate> userPredicates = new ArrayList<Predicate>();
private List<String> filters = new ArrayList<String>();
private List<Filter> userFilters = new ArrayList<Filter>();
private int order = 0;
private Map<String, Object> metadata = new HashMap<String, Object>();
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getUri() {
return uri;
}
public void setUri(String uri) {
this.uri = uri;
}
public List<String> getPredicates() {
return predicates;
}
public void setPredicates(List<String> predicates) {
this.predicates = predicates;
}
public List<Predicate> getUserPredicates() {
return userPredicates;
}
public void setUserPredicates(List<Predicate> userPredicates) {
this.userPredicates = userPredicates;
}
public List<String> getFilters() {
return filters;
}
public void setFilters(List<String> filters) {
this.filters = filters;
}
public List<Filter> getUserFilters() {
return userFilters;
}
public void setUserFilters(List<Filter> userFilters) {
this.userFilters = userFilters;
}
public int getOrder() {
return order;
}
public void setOrder(int order) {<FILL_FUNCTION_BODY>}
public Map<String, Object> getMetadata() {
return metadata;
}
public void setMetadata(Map<String, Object> metadata) {
if (metadata != null) {
this.metadata = metadata;
}
}
public static class Predicate extends Clause {
private static final long serialVersionUID = -5113611207453059195L;
@Override
public int hashCode() {
return HashCodeBuilder.reflectionHashCode(this);
}
@Override
public boolean equals(Object object) {
return EqualsBuilder.reflectionEquals(this, object);
}
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
}
}
public static class Filter extends Clause {
private static final long serialVersionUID = 4975847305584873755L;
@Override
public int hashCode() {
return HashCodeBuilder.reflectionHashCode(this);
}
@Override
public boolean equals(Object object) {
return EqualsBuilder.reflectionEquals(this, object);
}
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
}
}
public static class Clause implements Serializable {
private static final long serialVersionUID = -6284675851623689077L;
private String name;
private Map<String, String> args = new LinkedHashMap<>();
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Map<String, String> getArgs() {
return args;
}
public void setArgs(Map<String, String> args) {
this.args = args;
}
public void addArg(String key, String value) {
this.args.put(key, value);
}
@Override
public int hashCode() {
return HashCodeBuilder.reflectionHashCode(this);
}
@Override
public boolean equals(Object object) {
return EqualsBuilder.reflectionEquals(this, object);
}
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
}
}
public static <T extends Clause> String toClausesJson(List<T> clauses) {
StringBuilder stringBuilder = new StringBuilder();
for (Clause clause : clauses) {
stringBuilder.append(String.format("%s=%s, ", clause.getName(), JsonUtil.toJson(clause.getArgs())));
}
if (stringBuilder.length() > 0) {
stringBuilder.delete(stringBuilder.length() - 2, stringBuilder.length());
}
return stringBuilder.toString();
}
@Override
public int hashCode() {
return HashCodeBuilder.reflectionHashCode(this);
}
@Override
public boolean equals(Object object) {
return EqualsBuilder.reflectionEquals(this, object);
}
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
}
} |
this.order = order;
|
Nepxion_Discovery | Discovery/discovery-commons/discovery-common/src/main/java/com/nepxion/discovery/common/entity/GatewayStrategyRouteEntity.java | GatewayStrategyRouteEntity | getMetadata | class GatewayStrategyRouteEntity implements Serializable {
private static final long serialVersionUID = 8552414941889295450L;
private String id;
private String uri;
private List<String> predicates = new ArrayList<String>();
private List<Predicate> userPredicates = new ArrayList<Predicate>();
private List<String> filters = new ArrayList<String>();
private List<Filter> userFilters = new ArrayList<Filter>();
private int order = 0;
private Map<String, Object> metadata = new HashMap<String, Object>();
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getUri() {
return uri;
}
public void setUri(String uri) {
this.uri = uri;
}
public List<String> getPredicates() {
return predicates;
}
public void setPredicates(List<String> predicates) {
this.predicates = predicates;
}
public List<Predicate> getUserPredicates() {
return userPredicates;
}
public void setUserPredicates(List<Predicate> userPredicates) {
this.userPredicates = userPredicates;
}
public List<String> getFilters() {
return filters;
}
public void setFilters(List<String> filters) {
this.filters = filters;
}
public List<Filter> getUserFilters() {
return userFilters;
}
public void setUserFilters(List<Filter> userFilters) {
this.userFilters = userFilters;
}
public int getOrder() {
return order;
}
public void setOrder(int order) {
this.order = order;
}
public Map<String, Object> getMetadata() {<FILL_FUNCTION_BODY>}
public void setMetadata(Map<String, Object> metadata) {
if (metadata != null) {
this.metadata = metadata;
}
}
public static class Predicate extends Clause {
private static final long serialVersionUID = -5113611207453059195L;
@Override
public int hashCode() {
return HashCodeBuilder.reflectionHashCode(this);
}
@Override
public boolean equals(Object object) {
return EqualsBuilder.reflectionEquals(this, object);
}
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
}
}
public static class Filter extends Clause {
private static final long serialVersionUID = 4975847305584873755L;
@Override
public int hashCode() {
return HashCodeBuilder.reflectionHashCode(this);
}
@Override
public boolean equals(Object object) {
return EqualsBuilder.reflectionEquals(this, object);
}
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
}
}
public static class Clause implements Serializable {
private static final long serialVersionUID = -6284675851623689077L;
private String name;
private Map<String, String> args = new LinkedHashMap<>();
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Map<String, String> getArgs() {
return args;
}
public void setArgs(Map<String, String> args) {
this.args = args;
}
public void addArg(String key, String value) {
this.args.put(key, value);
}
@Override
public int hashCode() {
return HashCodeBuilder.reflectionHashCode(this);
}
@Override
public boolean equals(Object object) {
return EqualsBuilder.reflectionEquals(this, object);
}
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
}
}
public static <T extends Clause> String toClausesJson(List<T> clauses) {
StringBuilder stringBuilder = new StringBuilder();
for (Clause clause : clauses) {
stringBuilder.append(String.format("%s=%s, ", clause.getName(), JsonUtil.toJson(clause.getArgs())));
}
if (stringBuilder.length() > 0) {
stringBuilder.delete(stringBuilder.length() - 2, stringBuilder.length());
}
return stringBuilder.toString();
}
@Override
public int hashCode() {
return HashCodeBuilder.reflectionHashCode(this);
}
@Override
public boolean equals(Object object) {
return EqualsBuilder.reflectionEquals(this, object);
}
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
}
} |
return metadata;
|
Nepxion_Discovery | Discovery/discovery-commons/discovery-common/src/main/java/com/nepxion/discovery/common/entity/GatewayStrategyRouteEntity.java | GatewayStrategyRouteEntity | setMetadata | class GatewayStrategyRouteEntity implements Serializable {
private static final long serialVersionUID = 8552414941889295450L;
private String id;
private String uri;
private List<String> predicates = new ArrayList<String>();
private List<Predicate> userPredicates = new ArrayList<Predicate>();
private List<String> filters = new ArrayList<String>();
private List<Filter> userFilters = new ArrayList<Filter>();
private int order = 0;
private Map<String, Object> metadata = new HashMap<String, Object>();
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getUri() {
return uri;
}
public void setUri(String uri) {
this.uri = uri;
}
public List<String> getPredicates() {
return predicates;
}
public void setPredicates(List<String> predicates) {
this.predicates = predicates;
}
public List<Predicate> getUserPredicates() {
return userPredicates;
}
public void setUserPredicates(List<Predicate> userPredicates) {
this.userPredicates = userPredicates;
}
public List<String> getFilters() {
return filters;
}
public void setFilters(List<String> filters) {
this.filters = filters;
}
public List<Filter> getUserFilters() {
return userFilters;
}
public void setUserFilters(List<Filter> userFilters) {
this.userFilters = userFilters;
}
public int getOrder() {
return order;
}
public void setOrder(int order) {
this.order = order;
}
public Map<String, Object> getMetadata() {
return metadata;
}
public void setMetadata(Map<String, Object> metadata) {<FILL_FUNCTION_BODY>}
public static class Predicate extends Clause {
private static final long serialVersionUID = -5113611207453059195L;
@Override
public int hashCode() {
return HashCodeBuilder.reflectionHashCode(this);
}
@Override
public boolean equals(Object object) {
return EqualsBuilder.reflectionEquals(this, object);
}
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
}
}
public static class Filter extends Clause {
private static final long serialVersionUID = 4975847305584873755L;
@Override
public int hashCode() {
return HashCodeBuilder.reflectionHashCode(this);
}
@Override
public boolean equals(Object object) {
return EqualsBuilder.reflectionEquals(this, object);
}
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
}
}
public static class Clause implements Serializable {
private static final long serialVersionUID = -6284675851623689077L;
private String name;
private Map<String, String> args = new LinkedHashMap<>();
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Map<String, String> getArgs() {
return args;
}
public void setArgs(Map<String, String> args) {
this.args = args;
}
public void addArg(String key, String value) {
this.args.put(key, value);
}
@Override
public int hashCode() {
return HashCodeBuilder.reflectionHashCode(this);
}
@Override
public boolean equals(Object object) {
return EqualsBuilder.reflectionEquals(this, object);
}
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
}
}
public static <T extends Clause> String toClausesJson(List<T> clauses) {
StringBuilder stringBuilder = new StringBuilder();
for (Clause clause : clauses) {
stringBuilder.append(String.format("%s=%s, ", clause.getName(), JsonUtil.toJson(clause.getArgs())));
}
if (stringBuilder.length() > 0) {
stringBuilder.delete(stringBuilder.length() - 2, stringBuilder.length());
}
return stringBuilder.toString();
}
@Override
public int hashCode() {
return HashCodeBuilder.reflectionHashCode(this);
}
@Override
public boolean equals(Object object) {
return EqualsBuilder.reflectionEquals(this, object);
}
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
}
} |
if (metadata != null) {
this.metadata = metadata;
}
|
Nepxion_Discovery | Discovery/discovery-commons/discovery-common/src/main/java/com/nepxion/discovery/common/entity/GatewayStrategyRouteEntity.java | Predicate | hashCode | class Predicate extends Clause {
private static final long serialVersionUID = -5113611207453059195L;
@Override
public int hashCode() {<FILL_FUNCTION_BODY>}
@Override
public boolean equals(Object object) {
return EqualsBuilder.reflectionEquals(this, object);
}
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
}
} |
return HashCodeBuilder.reflectionHashCode(this);
|
Nepxion_Discovery | Discovery/discovery-commons/discovery-common/src/main/java/com/nepxion/discovery/common/entity/GatewayStrategyRouteEntity.java | Predicate | equals | class Predicate extends Clause {
private static final long serialVersionUID = -5113611207453059195L;
@Override
public int hashCode() {
return HashCodeBuilder.reflectionHashCode(this);
}
@Override
public boolean equals(Object object) {<FILL_FUNCTION_BODY>}
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
}
} |
return EqualsBuilder.reflectionEquals(this, object);
|
Nepxion_Discovery | Discovery/discovery-commons/discovery-common/src/main/java/com/nepxion/discovery/common/entity/GatewayStrategyRouteEntity.java | Predicate | toString | class Predicate extends Clause {
private static final long serialVersionUID = -5113611207453059195L;
@Override
public int hashCode() {
return HashCodeBuilder.reflectionHashCode(this);
}
@Override
public boolean equals(Object object) {
return EqualsBuilder.reflectionEquals(this, object);
}
@Override
public String toString() {<FILL_FUNCTION_BODY>}
} |
return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
|
Nepxion_Discovery | Discovery/discovery-commons/discovery-common/src/main/java/com/nepxion/discovery/common/entity/GatewayStrategyRouteEntity.java | Filter | hashCode | class Filter extends Clause {
private static final long serialVersionUID = 4975847305584873755L;
@Override
public int hashCode() {<FILL_FUNCTION_BODY>}
@Override
public boolean equals(Object object) {
return EqualsBuilder.reflectionEquals(this, object);
}
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
}
} |
return HashCodeBuilder.reflectionHashCode(this);
|
Nepxion_Discovery | Discovery/discovery-commons/discovery-common/src/main/java/com/nepxion/discovery/common/entity/GatewayStrategyRouteEntity.java | Filter | equals | class Filter extends Clause {
private static final long serialVersionUID = 4975847305584873755L;
@Override
public int hashCode() {
return HashCodeBuilder.reflectionHashCode(this);
}
@Override
public boolean equals(Object object) {<FILL_FUNCTION_BODY>}
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
}
} |
return EqualsBuilder.reflectionEquals(this, object);
|
Nepxion_Discovery | Discovery/discovery-commons/discovery-common/src/main/java/com/nepxion/discovery/common/entity/GatewayStrategyRouteEntity.java | Filter | toString | class Filter extends Clause {
private static final long serialVersionUID = 4975847305584873755L;
@Override
public int hashCode() {
return HashCodeBuilder.reflectionHashCode(this);
}
@Override
public boolean equals(Object object) {
return EqualsBuilder.reflectionEquals(this, object);
}
@Override
public String toString() {<FILL_FUNCTION_BODY>}
} |
return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
|
Nepxion_Discovery | Discovery/discovery-commons/discovery-common/src/main/java/com/nepxion/discovery/common/entity/GatewayStrategyRouteEntity.java | Clause | getName | class Clause implements Serializable {
private static final long serialVersionUID = -6284675851623689077L;
private String name;
private Map<String, String> args = new LinkedHashMap<>();
public String getName() {<FILL_FUNCTION_BODY>}
public void setName(String name) {
this.name = name;
}
public Map<String, String> getArgs() {
return args;
}
public void setArgs(Map<String, String> args) {
this.args = args;
}
public void addArg(String key, String value) {
this.args.put(key, value);
}
@Override
public int hashCode() {
return HashCodeBuilder.reflectionHashCode(this);
}
@Override
public boolean equals(Object object) {
return EqualsBuilder.reflectionEquals(this, object);
}
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
}
} |
return name;
|
Nepxion_Discovery | Discovery/discovery-commons/discovery-common/src/main/java/com/nepxion/discovery/common/entity/GatewayStrategyRouteEntity.java | Clause | setName | class Clause implements Serializable {
private static final long serialVersionUID = -6284675851623689077L;
private String name;
private Map<String, String> args = new LinkedHashMap<>();
public String getName() {
return name;
}
public void setName(String name) {<FILL_FUNCTION_BODY>}
public Map<String, String> getArgs() {
return args;
}
public void setArgs(Map<String, String> args) {
this.args = args;
}
public void addArg(String key, String value) {
this.args.put(key, value);
}
@Override
public int hashCode() {
return HashCodeBuilder.reflectionHashCode(this);
}
@Override
public boolean equals(Object object) {
return EqualsBuilder.reflectionEquals(this, object);
}
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
}
} |
this.name = name;
|
Nepxion_Discovery | Discovery/discovery-commons/discovery-common/src/main/java/com/nepxion/discovery/common/entity/GatewayStrategyRouteEntity.java | Clause | getArgs | class Clause implements Serializable {
private static final long serialVersionUID = -6284675851623689077L;
private String name;
private Map<String, String> args = new LinkedHashMap<>();
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Map<String, String> getArgs() {<FILL_FUNCTION_BODY>}
public void setArgs(Map<String, String> args) {
this.args = args;
}
public void addArg(String key, String value) {
this.args.put(key, value);
}
@Override
public int hashCode() {
return HashCodeBuilder.reflectionHashCode(this);
}
@Override
public boolean equals(Object object) {
return EqualsBuilder.reflectionEquals(this, object);
}
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
}
} |
return args;
|
Nepxion_Discovery | Discovery/discovery-commons/discovery-common/src/main/java/com/nepxion/discovery/common/entity/GatewayStrategyRouteEntity.java | Clause | setArgs | class Clause implements Serializable {
private static final long serialVersionUID = -6284675851623689077L;
private String name;
private Map<String, String> args = new LinkedHashMap<>();
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Map<String, String> getArgs() {
return args;
}
public void setArgs(Map<String, String> args) {<FILL_FUNCTION_BODY>}
public void addArg(String key, String value) {
this.args.put(key, value);
}
@Override
public int hashCode() {
return HashCodeBuilder.reflectionHashCode(this);
}
@Override
public boolean equals(Object object) {
return EqualsBuilder.reflectionEquals(this, object);
}
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
}
} |
this.args = args;
|
Nepxion_Discovery | Discovery/discovery-commons/discovery-common/src/main/java/com/nepxion/discovery/common/entity/GatewayStrategyRouteEntity.java | Clause | addArg | class Clause implements Serializable {
private static final long serialVersionUID = -6284675851623689077L;
private String name;
private Map<String, String> args = new LinkedHashMap<>();
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Map<String, String> getArgs() {
return args;
}
public void setArgs(Map<String, String> args) {
this.args = args;
}
public void addArg(String key, String value) {<FILL_FUNCTION_BODY>}
@Override
public int hashCode() {
return HashCodeBuilder.reflectionHashCode(this);
}
@Override
public boolean equals(Object object) {
return EqualsBuilder.reflectionEquals(this, object);
}
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
}
} |
this.args.put(key, value);
|
Nepxion_Discovery | Discovery/discovery-commons/discovery-common/src/main/java/com/nepxion/discovery/common/entity/GatewayStrategyRouteEntity.java | Clause | hashCode | class Clause implements Serializable {
private static final long serialVersionUID = -6284675851623689077L;
private String name;
private Map<String, String> args = new LinkedHashMap<>();
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Map<String, String> getArgs() {
return args;
}
public void setArgs(Map<String, String> args) {
this.args = args;
}
public void addArg(String key, String value) {
this.args.put(key, value);
}
@Override
public int hashCode() {<FILL_FUNCTION_BODY>}
@Override
public boolean equals(Object object) {
return EqualsBuilder.reflectionEquals(this, object);
}
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
}
} |
return HashCodeBuilder.reflectionHashCode(this);
|
Nepxion_Discovery | Discovery/discovery-commons/discovery-common/src/main/java/com/nepxion/discovery/common/entity/GatewayStrategyRouteEntity.java | Clause | equals | class Clause implements Serializable {
private static final long serialVersionUID = -6284675851623689077L;
private String name;
private Map<String, String> args = new LinkedHashMap<>();
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Map<String, String> getArgs() {
return args;
}
public void setArgs(Map<String, String> args) {
this.args = args;
}
public void addArg(String key, String value) {
this.args.put(key, value);
}
@Override
public int hashCode() {
return HashCodeBuilder.reflectionHashCode(this);
}
@Override
public boolean equals(Object object) {<FILL_FUNCTION_BODY>}
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
}
} |
return EqualsBuilder.reflectionEquals(this, object);
|
Nepxion_Discovery | Discovery/discovery-commons/discovery-common/src/main/java/com/nepxion/discovery/common/entity/GatewayStrategyRouteEntity.java | Clause | toString | class Clause implements Serializable {
private static final long serialVersionUID = -6284675851623689077L;
private String name;
private Map<String, String> args = new LinkedHashMap<>();
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Map<String, String> getArgs() {
return args;
}
public void setArgs(Map<String, String> args) {
this.args = args;
}
public void addArg(String key, String value) {
this.args.put(key, value);
}
@Override
public int hashCode() {
return HashCodeBuilder.reflectionHashCode(this);
}
@Override
public boolean equals(Object object) {
return EqualsBuilder.reflectionEquals(this, object);
}
@Override
public String toString() {<FILL_FUNCTION_BODY>}
} |
return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
|
Nepxion_Discovery | Discovery/discovery-commons/discovery-common/src/main/java/com/nepxion/discovery/common/entity/GatewayStrategyRouteEntity.java | Clause | toClausesJson | class Clause implements Serializable {
private static final long serialVersionUID = -6284675851623689077L;
private String name;
private Map<String, String> args = new LinkedHashMap<>();
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Map<String, String> getArgs() {
return args;
}
public void setArgs(Map<String, String> args) {
this.args = args;
}
public void addArg(String key, String value) {
this.args.put(key, value);
}
@Override
public int hashCode() {
return HashCodeBuilder.reflectionHashCode(this);
}
@Override
public boolean equals(Object object) {
return EqualsBuilder.reflectionEquals(this, object);
}
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
}
}
public static <T extends Clause> String toClausesJson(List<T> clauses) {<FILL_FUNCTION_BODY> |
StringBuilder stringBuilder = new StringBuilder();
for (Clause clause : clauses) {
stringBuilder.append(String.format("%s=%s, ", clause.getName(), JsonUtil.toJson(clause.getArgs())));
}
if (stringBuilder.length() > 0) {
stringBuilder.delete(stringBuilder.length() - 2, stringBuilder.length());
}
return stringBuilder.toString();
|
Nepxion_Discovery | Discovery/discovery-commons/discovery-common/src/main/java/com/nepxion/discovery/common/entity/GatewayStrategyRouteEntity.java | Clause | hashCode | class Clause implements Serializable {
private static final long serialVersionUID = -6284675851623689077L;
private String name;
private Map<String, String> args = new LinkedHashMap<>();
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Map<String, String> getArgs() {
return args;
}
public void setArgs(Map<String, String> args) {
this.args = args;
}
public void addArg(String key, String value) {
this.args.put(key, value);
}
@Override
public int hashCode() {
return HashCodeBuilder.reflectionHashCode(this);
}
@Override
public boolean equals(Object object) {
return EqualsBuilder.reflectionEquals(this, object);
}
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
}
}
public static <T extends Clause> String toClausesJson(List<T> clauses) {
StringBuilder stringBuilder = new StringBuilder();
for (Clause clause : clauses) {
stringBuilder.append(String.format("%s=%s, ", clause.getName(), JsonUtil.toJson(clause.getArgs())));
}
if (stringBuilder.length() > 0) {
stringBuilder.delete(stringBuilder.length() - 2, stringBuilder.length());
}
return stringBuilder.toString();
}
@Override
public int hashCode() {<FILL_FUNCTION_BODY> |
return HashCodeBuilder.reflectionHashCode(this);
|
Nepxion_Discovery | Discovery/discovery-commons/discovery-common/src/main/java/com/nepxion/discovery/common/entity/GatewayStrategyRouteEntity.java | Clause | equals | class Clause implements Serializable {
private static final long serialVersionUID = -6284675851623689077L;
private String name;
private Map<String, String> args = new LinkedHashMap<>();
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Map<String, String> getArgs() {
return args;
}
public void setArgs(Map<String, String> args) {
this.args = args;
}
public void addArg(String key, String value) {
this.args.put(key, value);
}
@Override
public int hashCode() {
return HashCodeBuilder.reflectionHashCode(this);
}
@Override
public boolean equals(Object object) {
return EqualsBuilder.reflectionEquals(this, object);
}
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
}
}
public static <T extends Clause> String toClausesJson(List<T> clauses) {
StringBuilder stringBuilder = new StringBuilder();
for (Clause clause : clauses) {
stringBuilder.append(String.format("%s=%s, ", clause.getName(), JsonUtil.toJson(clause.getArgs())));
}
if (stringBuilder.length() > 0) {
stringBuilder.delete(stringBuilder.length() - 2, stringBuilder.length());
}
return stringBuilder.toString();
}
@Override
public int hashCode() {
return HashCodeBuilder.reflectionHashCode(this);
}
@Override
public boolean equals(Object object) {<FILL_FUNCTION_BODY> |
return EqualsBuilder.reflectionEquals(this, object);
|
Nepxion_Discovery | Discovery/discovery-commons/discovery-common/src/main/java/com/nepxion/discovery/common/entity/GatewayStrategyRouteEntity.java | Clause | toString | class Clause implements Serializable {
private static final long serialVersionUID = -6284675851623689077L;
private String name;
private Map<String, String> args = new LinkedHashMap<>();
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Map<String, String> getArgs() {
return args;
}
public void setArgs(Map<String, String> args) {
this.args = args;
}
public void addArg(String key, String value) {
this.args.put(key, value);
}
@Override
public int hashCode() {
return HashCodeBuilder.reflectionHashCode(this);
}
@Override
public boolean equals(Object object) {
return EqualsBuilder.reflectionEquals(this, object);
}
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
}
}
public static <T extends Clause> String toClausesJson(List<T> clauses) {
StringBuilder stringBuilder = new StringBuilder();
for (Clause clause : clauses) {
stringBuilder.append(String.format("%s=%s, ", clause.getName(), JsonUtil.toJson(clause.getArgs())));
}
if (stringBuilder.length() > 0) {
stringBuilder.delete(stringBuilder.length() - 2, stringBuilder.length());
}
return stringBuilder.toString();
}
@Override
public int hashCode() {
return HashCodeBuilder.reflectionHashCode(this);
}
@Override
public boolean equals(Object object) {
return EqualsBuilder.reflectionEquals(this, object);
}
@Override
public String toString() {<FILL_FUNCTION_BODY> |
return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
|
Nepxion_Discovery | Discovery/discovery-commons/discovery-common/src/main/java/com/nepxion/discovery/common/util/JsonUtil.java | NullKeySerializer | serialize | class NullKeySerializer extends StdSerializer<Object> {
private static final long serialVersionUID = -9176767187240330396L;
public NullKeySerializer() {
this(null);
}
public NullKeySerializer(Class<Object> object) {
super(object);
}
@Override
public void serialize(Object value, JsonGenerator gen, SerializerProvider provider) throws IOException {<FILL_FUNCTION_BODY>}
} |
gen.writeFieldName(StringUtils.EMPTY);
|
Nepxion_Discovery | Discovery/discovery-commons/discovery-common/src/main/java/com/nepxion/discovery/common/util/JsonUtil.java | NullKeySerializer | toJson | class NullKeySerializer extends StdSerializer<Object> {
private static final long serialVersionUID = -9176767187240330396L;
public NullKeySerializer() {
this(null);
}
public NullKeySerializer(Class<Object> object) {
super(object);
}
@Override
public void serialize(Object value, JsonGenerator gen, SerializerProvider provider) throws IOException {
gen.writeFieldName(StringUtils.EMPTY);
}
}
public static <T> String toJson(T object) {<FILL_FUNCTION_BODY> |
if (object == null) {
throw new IllegalArgumentException("Object is null");
}
try {
return objectMapper.writeValueAsString(object);
} catch (JsonProcessingException e) {
throw new IllegalArgumentException(e.getMessage(), e);
}
|
Nepxion_Discovery | Discovery/discovery-commons/discovery-common/src/main/java/com/nepxion/discovery/common/util/JsonUtil.java | NullKeySerializer | toPrettyJson | class NullKeySerializer extends StdSerializer<Object> {
private static final long serialVersionUID = -9176767187240330396L;
public NullKeySerializer() {
this(null);
}
public NullKeySerializer(Class<Object> object) {
super(object);
}
@Override
public void serialize(Object value, JsonGenerator gen, SerializerProvider provider) throws IOException {
gen.writeFieldName(StringUtils.EMPTY);
}
}
public static <T> String toJson(T object) {
if (object == null) {
throw new IllegalArgumentException("Object is null");
}
try {
return objectMapper.writeValueAsString(object);
} catch (JsonProcessingException e) {
throw new IllegalArgumentException(e.getMessage(), e);
}
}
public static <T> String toPrettyJson(T object) {<FILL_FUNCTION_BODY> |
if (object == null) {
throw new IllegalArgumentException("Object is null");
}
try {
return objectMapper.writer(discoveryPrettyPrinter).writeValueAsString(object);
} catch (JsonProcessingException e) {
throw new IllegalArgumentException(e.getMessage(), e);
}
|
Nepxion_Discovery | Discovery/discovery-commons/discovery-common/src/main/java/com/nepxion/discovery/common/util/JsonUtil.java | NullKeySerializer | fromJson | class NullKeySerializer extends StdSerializer<Object> {
private static final long serialVersionUID = -9176767187240330396L;
public NullKeySerializer() {
this(null);
}
public NullKeySerializer(Class<Object> object) {
super(object);
}
@Override
public void serialize(Object value, JsonGenerator gen, SerializerProvider provider) throws IOException {
gen.writeFieldName(StringUtils.EMPTY);
}
}
public static <T> String toJson(T object) {
if (object == null) {
throw new IllegalArgumentException("Object is null");
}
try {
return objectMapper.writeValueAsString(object);
} catch (JsonProcessingException e) {
throw new IllegalArgumentException(e.getMessage(), e);
}
}
public static <T> String toPrettyJson(T object) {
if (object == null) {
throw new IllegalArgumentException("Object is null");
}
try {
return objectMapper.writer(discoveryPrettyPrinter).writeValueAsString(object);
} catch (JsonProcessingException e) {
throw new IllegalArgumentException(e.getMessage(), e);
}
}
public static <T> T fromJson(String json, Class<T> clazz) {<FILL_FUNCTION_BODY> |
if (StringUtils.isEmpty(json)) {
throw new IllegalArgumentException("Json is null or empty");
}
try {
return objectMapper.readValue(json, clazz);
} catch (Exception e) {
throw new IllegalArgumentException(e.getMessage(), e);
}
|
Nepxion_Discovery | Discovery/discovery-commons/discovery-common/src/main/java/com/nepxion/discovery/common/util/JsonUtil.java | NullKeySerializer | fromJson | class NullKeySerializer extends StdSerializer<Object> {
private static final long serialVersionUID = -9176767187240330396L;
public NullKeySerializer() {
this(null);
}
public NullKeySerializer(Class<Object> object) {
super(object);
}
@Override
public void serialize(Object value, JsonGenerator gen, SerializerProvider provider) throws IOException {
gen.writeFieldName(StringUtils.EMPTY);
}
}
public static <T> String toJson(T object) {
if (object == null) {
throw new IllegalArgumentException("Object is null");
}
try {
return objectMapper.writeValueAsString(object);
} catch (JsonProcessingException e) {
throw new IllegalArgumentException(e.getMessage(), e);
}
}
public static <T> String toPrettyJson(T object) {
if (object == null) {
throw new IllegalArgumentException("Object is null");
}
try {
return objectMapper.writer(discoveryPrettyPrinter).writeValueAsString(object);
} catch (JsonProcessingException e) {
throw new IllegalArgumentException(e.getMessage(), e);
}
}
public static <T> T fromJson(String json, Class<T> clazz) {
if (StringUtils.isEmpty(json)) {
throw new IllegalArgumentException("Json is null or empty");
}
try {
return objectMapper.readValue(json, clazz);
} catch (Exception e) {
throw new IllegalArgumentException(e.getMessage(), e);
}
}
public static <T> T fromJson(String json, TypeReference<T> typeReference) {<FILL_FUNCTION_BODY> |
if (StringUtils.isEmpty(json)) {
throw new IllegalArgumentException("Json is null or empty");
}
try {
return objectMapper.readValue(json, typeReference);
} catch (Exception e) {
throw new IllegalArgumentException(e.getMessage(), e);
}
|
Nepxion_Discovery | Discovery/discovery-commons/discovery-common/src/main/java/com/nepxion/discovery/common/util/JsonUtil.java | NullKeySerializer | isJsonFormat | class NullKeySerializer extends StdSerializer<Object> {
private static final long serialVersionUID = -9176767187240330396L;
public NullKeySerializer() {
this(null);
}
public NullKeySerializer(Class<Object> object) {
super(object);
}
@Override
public void serialize(Object value, JsonGenerator gen, SerializerProvider provider) throws IOException {
gen.writeFieldName(StringUtils.EMPTY);
}
}
public static <T> String toJson(T object) {
if (object == null) {
throw new IllegalArgumentException("Object is null");
}
try {
return objectMapper.writeValueAsString(object);
} catch (JsonProcessingException e) {
throw new IllegalArgumentException(e.getMessage(), e);
}
}
public static <T> String toPrettyJson(T object) {
if (object == null) {
throw new IllegalArgumentException("Object is null");
}
try {
return objectMapper.writer(discoveryPrettyPrinter).writeValueAsString(object);
} catch (JsonProcessingException e) {
throw new IllegalArgumentException(e.getMessage(), e);
}
}
public static <T> T fromJson(String json, Class<T> clazz) {
if (StringUtils.isEmpty(json)) {
throw new IllegalArgumentException("Json is null or empty");
}
try {
return objectMapper.readValue(json, clazz);
} catch (Exception e) {
throw new IllegalArgumentException(e.getMessage(), e);
}
}
public static <T> T fromJson(String json, TypeReference<T> typeReference) {
if (StringUtils.isEmpty(json)) {
throw new IllegalArgumentException("Json is null or empty");
}
try {
return objectMapper.readValue(json, typeReference);
} catch (Exception e) {
throw new IllegalArgumentException(e.getMessage(), e);
}
}
public static boolean isJsonFormat(String json) {<FILL_FUNCTION_BODY> |
if (StringUtils.isBlank(json)) {
return false;
}
try {
objectMapper.readTree(json);
return true;
} catch (Exception e) {
return false;
}
|
Nepxion_Discovery | Discovery/discovery-commons/discovery-common/src/main/java/com/nepxion/discovery/common/util/JsonUtil.java | NullKeySerializer | fromJsonMap | class NullKeySerializer extends StdSerializer<Object> {
private static final long serialVersionUID = -9176767187240330396L;
public NullKeySerializer() {
this(null);
}
public NullKeySerializer(Class<Object> object) {
super(object);
}
@Override
public void serialize(Object value, JsonGenerator gen, SerializerProvider provider) throws IOException {
gen.writeFieldName(StringUtils.EMPTY);
}
}
public static <T> String toJson(T object) {
if (object == null) {
throw new IllegalArgumentException("Object is null");
}
try {
return objectMapper.writeValueAsString(object);
} catch (JsonProcessingException e) {
throw new IllegalArgumentException(e.getMessage(), e);
}
}
public static <T> String toPrettyJson(T object) {
if (object == null) {
throw new IllegalArgumentException("Object is null");
}
try {
return objectMapper.writer(discoveryPrettyPrinter).writeValueAsString(object);
} catch (JsonProcessingException e) {
throw new IllegalArgumentException(e.getMessage(), e);
}
}
public static <T> T fromJson(String json, Class<T> clazz) {
if (StringUtils.isEmpty(json)) {
throw new IllegalArgumentException("Json is null or empty");
}
try {
return objectMapper.readValue(json, clazz);
} catch (Exception e) {
throw new IllegalArgumentException(e.getMessage(), e);
}
}
public static <T> T fromJson(String json, TypeReference<T> typeReference) {
if (StringUtils.isEmpty(json)) {
throw new IllegalArgumentException("Json is null or empty");
}
try {
return objectMapper.readValue(json, typeReference);
} catch (Exception e) {
throw new IllegalArgumentException(e.getMessage(), e);
}
}
public static boolean isJsonFormat(String json) {
if (StringUtils.isBlank(json)) {
return false;
}
try {
objectMapper.readTree(json);
return true;
} catch (Exception e) {
return false;
}
}
@SuppressWarnings("unchecked")
public static String fromJsonMap(String json, String key) {<FILL_FUNCTION_BODY> |
if (StringUtils.isEmpty(json)) {
return null;
}
String value = null;
try {
Map<String, String> map = fromJson(json, Map.class);
value = map.get(key);
} catch (Exception e) {
value = json;
}
return value;
|
Nepxion_Discovery | Discovery/discovery-commons/discovery-common/src/main/java/com/nepxion/discovery/common/util/JsonUtil.java | NullKeySerializer | getObjectMapper | class NullKeySerializer extends StdSerializer<Object> {
private static final long serialVersionUID = -9176767187240330396L;
public NullKeySerializer() {
this(null);
}
public NullKeySerializer(Class<Object> object) {
super(object);
}
@Override
public void serialize(Object value, JsonGenerator gen, SerializerProvider provider) throws IOException {
gen.writeFieldName(StringUtils.EMPTY);
}
}
public static <T> String toJson(T object) {
if (object == null) {
throw new IllegalArgumentException("Object is null");
}
try {
return objectMapper.writeValueAsString(object);
} catch (JsonProcessingException e) {
throw new IllegalArgumentException(e.getMessage(), e);
}
}
public static <T> String toPrettyJson(T object) {
if (object == null) {
throw new IllegalArgumentException("Object is null");
}
try {
return objectMapper.writer(discoveryPrettyPrinter).writeValueAsString(object);
} catch (JsonProcessingException e) {
throw new IllegalArgumentException(e.getMessage(), e);
}
}
public static <T> T fromJson(String json, Class<T> clazz) {
if (StringUtils.isEmpty(json)) {
throw new IllegalArgumentException("Json is null or empty");
}
try {
return objectMapper.readValue(json, clazz);
} catch (Exception e) {
throw new IllegalArgumentException(e.getMessage(), e);
}
}
public static <T> T fromJson(String json, TypeReference<T> typeReference) {
if (StringUtils.isEmpty(json)) {
throw new IllegalArgumentException("Json is null or empty");
}
try {
return objectMapper.readValue(json, typeReference);
} catch (Exception e) {
throw new IllegalArgumentException(e.getMessage(), e);
}
}
public static boolean isJsonFormat(String json) {
if (StringUtils.isBlank(json)) {
return false;
}
try {
objectMapper.readTree(json);
return true;
} catch (Exception e) {
return false;
}
}
@SuppressWarnings("unchecked")
public static String fromJsonMap(String json, String key) {
if (StringUtils.isEmpty(json)) {
return null;
}
String value = null;
try {
Map<String, String> map = fromJson(json, Map.class);
value = map.get(key);
} catch (Exception e) {
value = json;
}
return value;
}
public static ObjectMapper getObjectMapper() {<FILL_FUNCTION_BODY> |
return objectMapper;
|
HdrHistogram_HdrHistogram | HdrHistogram/src/main/java/org/HdrHistogram/HistogramLogScanner.java | LazyHistogramReader | allowGet | class LazyHistogramReader implements EncodableHistogramSupplier {
private final Scanner scanner;
private boolean gotIt = true;
private LazyHistogramReader(Scanner scanner)
{
this.scanner = scanner;
}
private void allowGet()
{<FILL_FUNCTION_BODY>}
@Override
public EncodableHistogram read() throws DataFormatException
{
// prevent double calls to this method
if (gotIt) {
throw new IllegalStateException();
}
gotIt = true;
final String compressedPayloadString = scanner.next();
final ByteBuffer buffer = ByteBuffer.wrap(Base64Helper.parseBase64Binary(compressedPayloadString));
EncodableHistogram histogram = EncodableHistogram.decodeFromCompressedByteBuffer(buffer, 0);
return histogram;
}
} |
gotIt = false;
|
HdrHistogram_HdrHistogram | HdrHistogram/src/main/java/org/HdrHistogram/HistogramLogScanner.java | LazyHistogramReader | read | class LazyHistogramReader implements EncodableHistogramSupplier {
private final Scanner scanner;
private boolean gotIt = true;
private LazyHistogramReader(Scanner scanner)
{
this.scanner = scanner;
}
private void allowGet()
{
gotIt = false;
}
@Override
public EncodableHistogram read() throws DataFormatException
{<FILL_FUNCTION_BODY>}
} |
// prevent double calls to this method
if (gotIt) {
throw new IllegalStateException();
}
gotIt = true;
final String compressedPayloadString = scanner.next();
final ByteBuffer buffer = ByteBuffer.wrap(Base64Helper.parseBase64Binary(compressedPayloadString));
EncodableHistogram histogram = EncodableHistogram.decodeFromCompressedByteBuffer(buffer, 0);
return histogram;
|
HdrHistogram_HdrHistogram | HdrHistogram/src/main/java/org/HdrHistogram/HistogramLogScanner.java | LazyHistogramReader | initScanner | class LazyHistogramReader implements EncodableHistogramSupplier {
private final Scanner scanner;
private boolean gotIt = true;
private LazyHistogramReader(Scanner scanner)
{
this.scanner = scanner;
}
private void allowGet()
{
gotIt = false;
}
@Override
public EncodableHistogram read() throws DataFormatException
{
// prevent double calls to this method
if (gotIt) {
throw new IllegalStateException();
}
gotIt = true;
final String compressedPayloadString = scanner.next();
final ByteBuffer buffer = ByteBuffer.wrap(Base64Helper.parseBase64Binary(compressedPayloadString));
EncodableHistogram histogram = EncodableHistogram.decodeFromCompressedByteBuffer(buffer, 0);
return histogram;
}
}
private final LazyHistogramReader lazyReader;
protected final Scanner scanner;
/**
* Constructs a new HistogramLogReader that produces intervals read from the specified file name.
* @param inputFileName The name of the file to read from
* @throws java.io.FileNotFoundException when unable to find inputFileName
*/
public HistogramLogScanner(final String inputFileName) throws FileNotFoundException {
this(new Scanner(new File(inputFileName)));
}
/**
* Constructs a new HistogramLogReader that produces intervals read from the specified InputStream. Note that
* log readers constructed through this constructor do not assume ownership of stream and will not close it on
* {@link #close()}.
*
* @param inputStream The InputStream to read from
*/
public HistogramLogScanner(final InputStream inputStream) {
this(new Scanner(inputStream));
}
/**
* Constructs a new HistogramLogReader that produces intervals read from the specified file.
* @param inputFile The File to read from
* @throws java.io.FileNotFoundException when unable to find inputFile
*/
public HistogramLogScanner(final File inputFile) throws FileNotFoundException {
this(new Scanner(inputFile));
}
private HistogramLogScanner(Scanner scanner)
{
this.scanner = scanner;
this.lazyReader = new LazyHistogramReader(scanner);
initScanner();
}
private void initScanner() {<FILL_FUNCTION_BODY> |
scanner.useLocale(Locale.US);
scanner.useDelimiter("[ ,\\r\\n]");
|
HdrHistogram_HdrHistogram | HdrHistogram/src/main/java/org/HdrHistogram/HistogramLogScanner.java | LazyHistogramReader | close | class LazyHistogramReader implements EncodableHistogramSupplier {
private final Scanner scanner;
private boolean gotIt = true;
private LazyHistogramReader(Scanner scanner)
{
this.scanner = scanner;
}
private void allowGet()
{
gotIt = false;
}
@Override
public EncodableHistogram read() throws DataFormatException
{
// prevent double calls to this method
if (gotIt) {
throw new IllegalStateException();
}
gotIt = true;
final String compressedPayloadString = scanner.next();
final ByteBuffer buffer = ByteBuffer.wrap(Base64Helper.parseBase64Binary(compressedPayloadString));
EncodableHistogram histogram = EncodableHistogram.decodeFromCompressedByteBuffer(buffer, 0);
return histogram;
}
}
private final LazyHistogramReader lazyReader;
protected final Scanner scanner;
/**
* Constructs a new HistogramLogReader that produces intervals read from the specified file name.
* @param inputFileName The name of the file to read from
* @throws java.io.FileNotFoundException when unable to find inputFileName
*/
public HistogramLogScanner(final String inputFileName) throws FileNotFoundException {
this(new Scanner(new File(inputFileName)));
}
/**
* Constructs a new HistogramLogReader that produces intervals read from the specified InputStream. Note that
* log readers constructed through this constructor do not assume ownership of stream and will not close it on
* {@link #close()}.
*
* @param inputStream The InputStream to read from
*/
public HistogramLogScanner(final InputStream inputStream) {
this(new Scanner(inputStream));
}
/**
* Constructs a new HistogramLogReader that produces intervals read from the specified file.
* @param inputFile The File to read from
* @throws java.io.FileNotFoundException when unable to find inputFile
*/
public HistogramLogScanner(final File inputFile) throws FileNotFoundException {
this(new Scanner(inputFile));
}
private HistogramLogScanner(Scanner scanner)
{
this.scanner = scanner;
this.lazyReader = new LazyHistogramReader(scanner);
initScanner();
}
private void initScanner() {
scanner.useLocale(Locale.US);
scanner.useDelimiter("[ ,\\r\\n]");
}
/**
* Close underlying scanner.
*/
@Override
public void close()
{<FILL_FUNCTION_BODY> |
scanner.close();
|
HdrHistogram_HdrHistogram | HdrHistogram/src/main/java/org/HdrHistogram/HistogramLogScanner.java | LazyHistogramReader | process | class LazyHistogramReader implements EncodableHistogramSupplier {
private final Scanner scanner;
private boolean gotIt = true;
private LazyHistogramReader(Scanner scanner)
{
this.scanner = scanner;
}
private void allowGet()
{
gotIt = false;
}
@Override
public EncodableHistogram read() throws DataFormatException
{
// prevent double calls to this method
if (gotIt) {
throw new IllegalStateException();
}
gotIt = true;
final String compressedPayloadString = scanner.next();
final ByteBuffer buffer = ByteBuffer.wrap(Base64Helper.parseBase64Binary(compressedPayloadString));
EncodableHistogram histogram = EncodableHistogram.decodeFromCompressedByteBuffer(buffer, 0);
return histogram;
}
}
private final LazyHistogramReader lazyReader;
protected final Scanner scanner;
/**
* Constructs a new HistogramLogReader that produces intervals read from the specified file name.
* @param inputFileName The name of the file to read from
* @throws java.io.FileNotFoundException when unable to find inputFileName
*/
public HistogramLogScanner(final String inputFileName) throws FileNotFoundException {
this(new Scanner(new File(inputFileName)));
}
/**
* Constructs a new HistogramLogReader that produces intervals read from the specified InputStream. Note that
* log readers constructed through this constructor do not assume ownership of stream and will not close it on
* {@link #close()}.
*
* @param inputStream The InputStream to read from
*/
public HistogramLogScanner(final InputStream inputStream) {
this(new Scanner(inputStream));
}
/**
* Constructs a new HistogramLogReader that produces intervals read from the specified file.
* @param inputFile The File to read from
* @throws java.io.FileNotFoundException when unable to find inputFile
*/
public HistogramLogScanner(final File inputFile) throws FileNotFoundException {
this(new Scanner(inputFile));
}
private HistogramLogScanner(Scanner scanner)
{
this.scanner = scanner;
this.lazyReader = new LazyHistogramReader(scanner);
initScanner();
}
private void initScanner() {
scanner.useLocale(Locale.US);
scanner.useDelimiter("[ ,\\r\\n]");
}
/**
* Close underlying scanner.
*/
@Override
public void close()
{
scanner.close();
}
public void process(EventHandler handler) {<FILL_FUNCTION_BODY> |
while (scanner.hasNextLine()) {
try {
if (scanner.hasNext("\\#.*")) {
// comment line.
// Look for explicit start time or base time notes in comments:
if (scanner.hasNext("#\\[StartTime:")) {
scanner.next("#\\[StartTime:");
if (scanner.hasNextDouble()) {
double startTimeSec = scanner.nextDouble(); // start time represented as seconds since epoch
if (handler.onStartTime(startTimeSec)) {
return;
}
}
} else if (scanner.hasNext("#\\[BaseTime:")) {
scanner.next("#\\[BaseTime:");
if (scanner.hasNextDouble()) {
double baseTimeSec = scanner.nextDouble(); // base time represented as seconds since epoch
if (handler.onBaseTime(baseTimeSec))
{
return;
}
}
} else if (handler.onComment(scanner.next("\\#.*"))) {
return;
}
continue;
}
if (scanner.hasNext("\"StartTimestamp\".*")) {
// Legend line
continue;
}
String tagString = null;
if (scanner.hasNext("Tag\\=.*")) {
tagString = scanner.next("Tag\\=.*").substring(4);
}
// Decode: startTimestamp, intervalLength, maxTime, histogramPayload
final double logTimeStampInSec = scanner.nextDouble(); // Timestamp is expected to be in seconds
final double intervalLengthSec = scanner.nextDouble(); // Timestamp length is expect to be in seconds
scanner.nextDouble(); // Skip maxTime field, as max time can be deduced from the histogram.
lazyReader.allowGet();
if (handler.onHistogram(tagString, logTimeStampInSec, intervalLengthSec, lazyReader)) {
return;
}
} catch (Throwable ex) {
if (handler.onException(ex)) {
return;
}
} finally {
scanner.nextLine(); // Move to next line.
}
}
|
HdrHistogram_HdrHistogram | HdrHistogram/src/main/java/org/HdrHistogram/HistogramLogScanner.java | LazyHistogramReader | hasNextLine | class LazyHistogramReader implements EncodableHistogramSupplier {
private final Scanner scanner;
private boolean gotIt = true;
private LazyHistogramReader(Scanner scanner)
{
this.scanner = scanner;
}
private void allowGet()
{
gotIt = false;
}
@Override
public EncodableHistogram read() throws DataFormatException
{
// prevent double calls to this method
if (gotIt) {
throw new IllegalStateException();
}
gotIt = true;
final String compressedPayloadString = scanner.next();
final ByteBuffer buffer = ByteBuffer.wrap(Base64Helper.parseBase64Binary(compressedPayloadString));
EncodableHistogram histogram = EncodableHistogram.decodeFromCompressedByteBuffer(buffer, 0);
return histogram;
}
}
private final LazyHistogramReader lazyReader;
protected final Scanner scanner;
/**
* Constructs a new HistogramLogReader that produces intervals read from the specified file name.
* @param inputFileName The name of the file to read from
* @throws java.io.FileNotFoundException when unable to find inputFileName
*/
public HistogramLogScanner(final String inputFileName) throws FileNotFoundException {
this(new Scanner(new File(inputFileName)));
}
/**
* Constructs a new HistogramLogReader that produces intervals read from the specified InputStream. Note that
* log readers constructed through this constructor do not assume ownership of stream and will not close it on
* {@link #close()}.
*
* @param inputStream The InputStream to read from
*/
public HistogramLogScanner(final InputStream inputStream) {
this(new Scanner(inputStream));
}
/**
* Constructs a new HistogramLogReader that produces intervals read from the specified file.
* @param inputFile The File to read from
* @throws java.io.FileNotFoundException when unable to find inputFile
*/
public HistogramLogScanner(final File inputFile) throws FileNotFoundException {
this(new Scanner(inputFile));
}
private HistogramLogScanner(Scanner scanner)
{
this.scanner = scanner;
this.lazyReader = new LazyHistogramReader(scanner);
initScanner();
}
private void initScanner() {
scanner.useLocale(Locale.US);
scanner.useDelimiter("[ ,\\r\\n]");
}
/**
* Close underlying scanner.
*/
@Override
public void close()
{
scanner.close();
}
public void process(EventHandler handler) {
while (scanner.hasNextLine()) {
try {
if (scanner.hasNext("\\#.*")) {
// comment line.
// Look for explicit start time or base time notes in comments:
if (scanner.hasNext("#\\[StartTime:")) {
scanner.next("#\\[StartTime:");
if (scanner.hasNextDouble()) {
double startTimeSec = scanner.nextDouble(); // start time represented as seconds since epoch
if (handler.onStartTime(startTimeSec)) {
return;
}
}
} else if (scanner.hasNext("#\\[BaseTime:")) {
scanner.next("#\\[BaseTime:");
if (scanner.hasNextDouble()) {
double baseTimeSec = scanner.nextDouble(); // base time represented as seconds since epoch
if (handler.onBaseTime(baseTimeSec))
{
return;
}
}
} else if (handler.onComment(scanner.next("\\#.*"))) {
return;
}
continue;
}
if (scanner.hasNext("\"StartTimestamp\".*")) {
// Legend line
continue;
}
String tagString = null;
if (scanner.hasNext("Tag\\=.*")) {
tagString = scanner.next("Tag\\=.*").substring(4);
}
// Decode: startTimestamp, intervalLength, maxTime, histogramPayload
final double logTimeStampInSec = scanner.nextDouble(); // Timestamp is expected to be in seconds
final double intervalLengthSec = scanner.nextDouble(); // Timestamp length is expect to be in seconds
scanner.nextDouble(); // Skip maxTime field, as max time can be deduced from the histogram.
lazyReader.allowGet();
if (handler.onHistogram(tagString, logTimeStampInSec, intervalLengthSec, lazyReader)) {
return;
}
} catch (Throwable ex) {
if (handler.onException(ex)) {
return;
}
} finally {
scanner.nextLine(); // Move to next line.
}
}
}
/**
* Indicates whether or not additional intervals may exist in the log
*
* @return true if additional intervals may exist in the log
*/
public boolean hasNextLine() {<FILL_FUNCTION_BODY> |
return scanner.hasNextLine();
|
HdrHistogram_HdrHistogram | HdrHistogram/src/main/java/org/HdrHistogram/SingleWriterDoubleRecorder.java | SingleWriterDoubleRecorder | recordValue | class SingleWriterDoubleRecorder implements DoubleValueRecorder, IntervalHistogramProvider<DoubleHistogram> {
private static AtomicLong instanceIdSequencer = new AtomicLong(1);
private final long instanceId = instanceIdSequencer.getAndIncrement();
private final WriterReaderPhaser recordingPhaser = new WriterReaderPhaser();
private volatile DoubleHistogram activeHistogram;
private DoubleHistogram inactiveHistogram;
/**
* Construct an auto-resizing {@link SingleWriterDoubleRecorder} using a precision stated as a
* number of significant decimal digits.
* <p>
* Depending on the valuer of the <b><code>packed</code></b> parameter {@link SingleWriterDoubleRecorder} can
* be configured to track value counts in a packed internal representation optimized for typical histogram
* recoded values are sparse in the value range and tend to be incremented in small unit counts. This packed
* representation tends to require significantly smaller amounts of storage when compared to unpacked
* representations, but can incur additional recording cost due to resizing and repacking operations that may
* occur as previously unrecorded values are encountered.
*
* @param numberOfSignificantValueDigits Specifies the precision to use. This is the number of significant
* decimal digits to which the histogram will maintain value resolution
* and separation. Must be a non-negative integer between 0 and 5.
* @param packed Specifies whether the recorder will uses a packed internal representation or not.
*/
public SingleWriterDoubleRecorder(final int numberOfSignificantValueDigits, final boolean packed) {
activeHistogram = packed ?
new PackedInternalDoubleHistogram(instanceId, numberOfSignificantValueDigits) :
new InternalDoubleHistogram(instanceId, numberOfSignificantValueDigits);
inactiveHistogram = null;
activeHistogram.setStartTimeStamp(System.currentTimeMillis());
}
/**
* Construct an auto-resizing {@link SingleWriterDoubleRecorder} using a precision stated as a
* number of significant decimal digits.
*
* @param numberOfSignificantValueDigits Specifies the precision to use. This is the number of significant
* decimal digits to which the histogram will maintain value resolution
* and separation. Must be a non-negative integer between 0 and 5.
*/
public SingleWriterDoubleRecorder(final int numberOfSignificantValueDigits) {
this(numberOfSignificantValueDigits, false);
}
/**
* Construct a {@link SingleWriterDoubleRecorder} dynamic range of values to cover and a number
* of significant decimal digits.
*
* @param highestToLowestValueRatio specifies the dynamic range to use (as a ratio)
* @param numberOfSignificantValueDigits Specifies the precision to use. This is the number of significant
* decimal digits to which the histogram will maintain value resolution
* and separation. Must be a non-negative integer between 0 and 5.
*/
public SingleWriterDoubleRecorder(final long highestToLowestValueRatio,
final int numberOfSignificantValueDigits) {
activeHistogram = new InternalDoubleHistogram(
instanceId, highestToLowestValueRatio, numberOfSignificantValueDigits);
inactiveHistogram = null;
activeHistogram.setStartTimeStamp(System.currentTimeMillis());
}
/**
* Record a value
* @param value the value to record
* @throws ArrayIndexOutOfBoundsException (may throw) if value is exceeds highestTrackableValue
*/
public void recordValue(final double value) {<FILL_FUNCTION_BODY>}
/**
* Record a value in the histogram (adding to the value's current count)
*
* @param value The value to be recorded
* @param count The number of occurrences of this value to record
* @throws ArrayIndexOutOfBoundsException (may throw) if value is exceeds highestTrackableValue
*/
public void recordValueWithCount(final double value, final long count) throws ArrayIndexOutOfBoundsException {
long criticalValueAtEnter = recordingPhaser.writerCriticalSectionEnter();
try {
activeHistogram.recordValueWithCount(value, count);
} finally {
recordingPhaser.writerCriticalSectionExit(criticalValueAtEnter);
}
}
/**
* Record a value
* <p>
* To compensate for the loss of sampled values when a recorded value is larger than the expected
* interval between value samples, Histogram will auto-generate an additional series of decreasingly-smaller
* (down to the expectedIntervalBetweenValueSamples) value records.
* <p>
* See related notes {@link org.HdrHistogram.DoubleHistogram#recordValueWithExpectedInterval(double, double)}
* for more explanations about coordinated omission and expected interval correction.
* *
* @param value The value to record
* @param expectedIntervalBetweenValueSamples If expectedIntervalBetweenValueSamples is larger than 0, add
* auto-generated value records as appropriate if value is larger
* than expectedIntervalBetweenValueSamples
* @throws ArrayIndexOutOfBoundsException (may throw) if value is exceeds highestTrackableValue
*/
public void recordValueWithExpectedInterval(final double value, final double expectedIntervalBetweenValueSamples)
throws ArrayIndexOutOfBoundsException {
long criticalValueAtEnter = recordingPhaser.writerCriticalSectionEnter();
try {
activeHistogram.recordValueWithExpectedInterval(value, expectedIntervalBetweenValueSamples);
} finally {
recordingPhaser.writerCriticalSectionExit(criticalValueAtEnter);
}
}
@Override
public synchronized DoubleHistogram getIntervalHistogram() {
return getIntervalHistogram(null);
}
@Override
public synchronized DoubleHistogram getIntervalHistogram(DoubleHistogram histogramToRecycle) {
return getIntervalHistogram(histogramToRecycle, true);
}
@Override
public synchronized DoubleHistogram getIntervalHistogram(DoubleHistogram histogramToRecycle,
boolean enforceContainingInstance) {
// Verify that replacement histogram can validly be used as an inactive histogram replacement:
validateFitAsReplacementHistogram(histogramToRecycle, enforceContainingInstance);
inactiveHistogram = histogramToRecycle;
performIntervalSample();
DoubleHistogram sampledHistogram = inactiveHistogram;
inactiveHistogram = null; // Once we expose the sample, we can't reuse it internally until it is recycled
return sampledHistogram;
}
@Override
public synchronized void getIntervalHistogramInto(DoubleHistogram targetHistogram) {
performIntervalSample();
inactiveHistogram.copyInto(targetHistogram);
}
/**
* Reset any value counts accumulated thus far.
*/
public synchronized void reset() {
// the currently inactive histogram is reset each time we flip. So flipping twice resets both:
performIntervalSample();
performIntervalSample();
}
private void performIntervalSample() {
try {
recordingPhaser.readerLock();
// Make sure we have an inactive version to flip in:
if (inactiveHistogram == null) {
if (activeHistogram instanceof InternalDoubleHistogram) {
inactiveHistogram = new InternalDoubleHistogram((InternalDoubleHistogram) activeHistogram);
} else if (activeHistogram instanceof PackedInternalDoubleHistogram) {
inactiveHistogram = new PackedInternalDoubleHistogram(
instanceId, activeHistogram.getNumberOfSignificantValueDigits());
} else {
throw new IllegalStateException("Unexpected internal histogram type for activeHistogram");
}
}
inactiveHistogram.reset();
// Swap active and inactive histograms:
final DoubleHistogram tempHistogram = inactiveHistogram;
inactiveHistogram = activeHistogram;
activeHistogram = tempHistogram;
// Mark end time of previous interval and start time of new one:
long now = System.currentTimeMillis();
activeHistogram.setStartTimeStamp(now);
inactiveHistogram.setEndTimeStamp(now);
// Make sure we are not in the middle of recording a value on the previously active histogram:
// Flip phase to make sure no recordings that were in flight pre-flip are still active:
recordingPhaser.flipPhase(500000L /* yield in 0.5 msec units if needed */);
} finally {
recordingPhaser.readerUnlock();
}
}
private class InternalDoubleHistogram extends DoubleHistogram {
private final long containingInstanceId;
private InternalDoubleHistogram(long id, int numberOfSignificantValueDigits) {
super(numberOfSignificantValueDigits);
this.containingInstanceId = id;
}
private InternalDoubleHistogram(long id,
long highestToLowestValueRatio,
int numberOfSignificantValueDigits) {
super(highestToLowestValueRatio, numberOfSignificantValueDigits);
this.containingInstanceId = id;
}
private InternalDoubleHistogram(InternalDoubleHistogram source) {
super(source);
this.containingInstanceId = source.containingInstanceId;
}
}
private class PackedInternalDoubleHistogram extends PackedDoubleHistogram {
private final long containingInstanceId;
private PackedInternalDoubleHistogram(long id, int numberOfSignificantValueDigits) {
super(numberOfSignificantValueDigits);
this.containingInstanceId = id;
}
}
private void validateFitAsReplacementHistogram(DoubleHistogram replacementHistogram,
boolean enforceContainingInstance) {
boolean bad = true;
if (replacementHistogram == null) {
bad = false;
} else if ((replacementHistogram instanceof InternalDoubleHistogram)
&&
((!enforceContainingInstance) ||
(((InternalDoubleHistogram) replacementHistogram).containingInstanceId ==
((InternalDoubleHistogram)activeHistogram).containingInstanceId)
)) {
bad = false;
} else if ((replacementHistogram instanceof PackedInternalDoubleHistogram)
&&
((!enforceContainingInstance) ||
(((PackedInternalDoubleHistogram) replacementHistogram).containingInstanceId ==
((PackedInternalDoubleHistogram)activeHistogram).containingInstanceId)
)) {
bad = false;
}
if (bad) {
throw new IllegalArgumentException("replacement histogram must have been obtained via a previous " +
"getIntervalHistogram() call from this " + this.getClass().getName() +" instance");
}
}
} |
long criticalValueAtEnter = recordingPhaser.writerCriticalSectionEnter();
try {
activeHistogram.recordValue(value);
} finally {
recordingPhaser.writerCriticalSectionExit(criticalValueAtEnter);
}
|
HdrHistogram_HdrHistogram | HdrHistogram/src/main/java/org/HdrHistogram/SingleWriterDoubleRecorder.java | SingleWriterDoubleRecorder | recordValueWithCount | class SingleWriterDoubleRecorder implements DoubleValueRecorder, IntervalHistogramProvider<DoubleHistogram> {
private static AtomicLong instanceIdSequencer = new AtomicLong(1);
private final long instanceId = instanceIdSequencer.getAndIncrement();
private final WriterReaderPhaser recordingPhaser = new WriterReaderPhaser();
private volatile DoubleHistogram activeHistogram;
private DoubleHistogram inactiveHistogram;
/**
* Construct an auto-resizing {@link SingleWriterDoubleRecorder} using a precision stated as a
* number of significant decimal digits.
* <p>
* Depending on the valuer of the <b><code>packed</code></b> parameter {@link SingleWriterDoubleRecorder} can
* be configured to track value counts in a packed internal representation optimized for typical histogram
* recoded values are sparse in the value range and tend to be incremented in small unit counts. This packed
* representation tends to require significantly smaller amounts of storage when compared to unpacked
* representations, but can incur additional recording cost due to resizing and repacking operations that may
* occur as previously unrecorded values are encountered.
*
* @param numberOfSignificantValueDigits Specifies the precision to use. This is the number of significant
* decimal digits to which the histogram will maintain value resolution
* and separation. Must be a non-negative integer between 0 and 5.
* @param packed Specifies whether the recorder will uses a packed internal representation or not.
*/
public SingleWriterDoubleRecorder(final int numberOfSignificantValueDigits, final boolean packed) {
activeHistogram = packed ?
new PackedInternalDoubleHistogram(instanceId, numberOfSignificantValueDigits) :
new InternalDoubleHistogram(instanceId, numberOfSignificantValueDigits);
inactiveHistogram = null;
activeHistogram.setStartTimeStamp(System.currentTimeMillis());
}
/**
* Construct an auto-resizing {@link SingleWriterDoubleRecorder} using a precision stated as a
* number of significant decimal digits.
*
* @param numberOfSignificantValueDigits Specifies the precision to use. This is the number of significant
* decimal digits to which the histogram will maintain value resolution
* and separation. Must be a non-negative integer between 0 and 5.
*/
public SingleWriterDoubleRecorder(final int numberOfSignificantValueDigits) {
this(numberOfSignificantValueDigits, false);
}
/**
* Construct a {@link SingleWriterDoubleRecorder} dynamic range of values to cover and a number
* of significant decimal digits.
*
* @param highestToLowestValueRatio specifies the dynamic range to use (as a ratio)
* @param numberOfSignificantValueDigits Specifies the precision to use. This is the number of significant
* decimal digits to which the histogram will maintain value resolution
* and separation. Must be a non-negative integer between 0 and 5.
*/
public SingleWriterDoubleRecorder(final long highestToLowestValueRatio,
final int numberOfSignificantValueDigits) {
activeHistogram = new InternalDoubleHistogram(
instanceId, highestToLowestValueRatio, numberOfSignificantValueDigits);
inactiveHistogram = null;
activeHistogram.setStartTimeStamp(System.currentTimeMillis());
}
/**
* Record a value
* @param value the value to record
* @throws ArrayIndexOutOfBoundsException (may throw) if value is exceeds highestTrackableValue
*/
public void recordValue(final double value) {
long criticalValueAtEnter = recordingPhaser.writerCriticalSectionEnter();
try {
activeHistogram.recordValue(value);
} finally {
recordingPhaser.writerCriticalSectionExit(criticalValueAtEnter);
}
}
/**
* Record a value in the histogram (adding to the value's current count)
*
* @param value The value to be recorded
* @param count The number of occurrences of this value to record
* @throws ArrayIndexOutOfBoundsException (may throw) if value is exceeds highestTrackableValue
*/
public void recordValueWithCount(final double value, final long count) throws ArrayIndexOutOfBoundsException {<FILL_FUNCTION_BODY>}
/**
* Record a value
* <p>
* To compensate for the loss of sampled values when a recorded value is larger than the expected
* interval between value samples, Histogram will auto-generate an additional series of decreasingly-smaller
* (down to the expectedIntervalBetweenValueSamples) value records.
* <p>
* See related notes {@link org.HdrHistogram.DoubleHistogram#recordValueWithExpectedInterval(double, double)}
* for more explanations about coordinated omission and expected interval correction.
* *
* @param value The value to record
* @param expectedIntervalBetweenValueSamples If expectedIntervalBetweenValueSamples is larger than 0, add
* auto-generated value records as appropriate if value is larger
* than expectedIntervalBetweenValueSamples
* @throws ArrayIndexOutOfBoundsException (may throw) if value is exceeds highestTrackableValue
*/
public void recordValueWithExpectedInterval(final double value, final double expectedIntervalBetweenValueSamples)
throws ArrayIndexOutOfBoundsException {
long criticalValueAtEnter = recordingPhaser.writerCriticalSectionEnter();
try {
activeHistogram.recordValueWithExpectedInterval(value, expectedIntervalBetweenValueSamples);
} finally {
recordingPhaser.writerCriticalSectionExit(criticalValueAtEnter);
}
}
@Override
public synchronized DoubleHistogram getIntervalHistogram() {
return getIntervalHistogram(null);
}
@Override
public synchronized DoubleHistogram getIntervalHistogram(DoubleHistogram histogramToRecycle) {
return getIntervalHistogram(histogramToRecycle, true);
}
@Override
public synchronized DoubleHistogram getIntervalHistogram(DoubleHistogram histogramToRecycle,
boolean enforceContainingInstance) {
// Verify that replacement histogram can validly be used as an inactive histogram replacement:
validateFitAsReplacementHistogram(histogramToRecycle, enforceContainingInstance);
inactiveHistogram = histogramToRecycle;
performIntervalSample();
DoubleHistogram sampledHistogram = inactiveHistogram;
inactiveHistogram = null; // Once we expose the sample, we can't reuse it internally until it is recycled
return sampledHistogram;
}
@Override
public synchronized void getIntervalHistogramInto(DoubleHistogram targetHistogram) {
performIntervalSample();
inactiveHistogram.copyInto(targetHistogram);
}
/**
* Reset any value counts accumulated thus far.
*/
public synchronized void reset() {
// the currently inactive histogram is reset each time we flip. So flipping twice resets both:
performIntervalSample();
performIntervalSample();
}
private void performIntervalSample() {
try {
recordingPhaser.readerLock();
// Make sure we have an inactive version to flip in:
if (inactiveHistogram == null) {
if (activeHistogram instanceof InternalDoubleHistogram) {
inactiveHistogram = new InternalDoubleHistogram((InternalDoubleHistogram) activeHistogram);
} else if (activeHistogram instanceof PackedInternalDoubleHistogram) {
inactiveHistogram = new PackedInternalDoubleHistogram(
instanceId, activeHistogram.getNumberOfSignificantValueDigits());
} else {
throw new IllegalStateException("Unexpected internal histogram type for activeHistogram");
}
}
inactiveHistogram.reset();
// Swap active and inactive histograms:
final DoubleHistogram tempHistogram = inactiveHistogram;
inactiveHistogram = activeHistogram;
activeHistogram = tempHistogram;
// Mark end time of previous interval and start time of new one:
long now = System.currentTimeMillis();
activeHistogram.setStartTimeStamp(now);
inactiveHistogram.setEndTimeStamp(now);
// Make sure we are not in the middle of recording a value on the previously active histogram:
// Flip phase to make sure no recordings that were in flight pre-flip are still active:
recordingPhaser.flipPhase(500000L /* yield in 0.5 msec units if needed */);
} finally {
recordingPhaser.readerUnlock();
}
}
private class InternalDoubleHistogram extends DoubleHistogram {
private final long containingInstanceId;
private InternalDoubleHistogram(long id, int numberOfSignificantValueDigits) {
super(numberOfSignificantValueDigits);
this.containingInstanceId = id;
}
private InternalDoubleHistogram(long id,
long highestToLowestValueRatio,
int numberOfSignificantValueDigits) {
super(highestToLowestValueRatio, numberOfSignificantValueDigits);
this.containingInstanceId = id;
}
private InternalDoubleHistogram(InternalDoubleHistogram source) {
super(source);
this.containingInstanceId = source.containingInstanceId;
}
}
private class PackedInternalDoubleHistogram extends PackedDoubleHistogram {
private final long containingInstanceId;
private PackedInternalDoubleHistogram(long id, int numberOfSignificantValueDigits) {
super(numberOfSignificantValueDigits);
this.containingInstanceId = id;
}
}
private void validateFitAsReplacementHistogram(DoubleHistogram replacementHistogram,
boolean enforceContainingInstance) {
boolean bad = true;
if (replacementHistogram == null) {
bad = false;
} else if ((replacementHistogram instanceof InternalDoubleHistogram)
&&
((!enforceContainingInstance) ||
(((InternalDoubleHistogram) replacementHistogram).containingInstanceId ==
((InternalDoubleHistogram)activeHistogram).containingInstanceId)
)) {
bad = false;
} else if ((replacementHistogram instanceof PackedInternalDoubleHistogram)
&&
((!enforceContainingInstance) ||
(((PackedInternalDoubleHistogram) replacementHistogram).containingInstanceId ==
((PackedInternalDoubleHistogram)activeHistogram).containingInstanceId)
)) {
bad = false;
}
if (bad) {
throw new IllegalArgumentException("replacement histogram must have been obtained via a previous " +
"getIntervalHistogram() call from this " + this.getClass().getName() +" instance");
}
}
} |
long criticalValueAtEnter = recordingPhaser.writerCriticalSectionEnter();
try {
activeHistogram.recordValueWithCount(value, count);
} finally {
recordingPhaser.writerCriticalSectionExit(criticalValueAtEnter);
}
|
HdrHistogram_HdrHistogram | HdrHistogram/src/main/java/org/HdrHistogram/SingleWriterDoubleRecorder.java | SingleWriterDoubleRecorder | recordValueWithExpectedInterval | class SingleWriterDoubleRecorder implements DoubleValueRecorder, IntervalHistogramProvider<DoubleHistogram> {
private static AtomicLong instanceIdSequencer = new AtomicLong(1);
private final long instanceId = instanceIdSequencer.getAndIncrement();
private final WriterReaderPhaser recordingPhaser = new WriterReaderPhaser();
private volatile DoubleHistogram activeHistogram;
private DoubleHistogram inactiveHistogram;
/**
* Construct an auto-resizing {@link SingleWriterDoubleRecorder} using a precision stated as a
* number of significant decimal digits.
* <p>
* Depending on the valuer of the <b><code>packed</code></b> parameter {@link SingleWriterDoubleRecorder} can
* be configured to track value counts in a packed internal representation optimized for typical histogram
* recoded values are sparse in the value range and tend to be incremented in small unit counts. This packed
* representation tends to require significantly smaller amounts of storage when compared to unpacked
* representations, but can incur additional recording cost due to resizing and repacking operations that may
* occur as previously unrecorded values are encountered.
*
* @param numberOfSignificantValueDigits Specifies the precision to use. This is the number of significant
* decimal digits to which the histogram will maintain value resolution
* and separation. Must be a non-negative integer between 0 and 5.
* @param packed Specifies whether the recorder will uses a packed internal representation or not.
*/
public SingleWriterDoubleRecorder(final int numberOfSignificantValueDigits, final boolean packed) {
activeHistogram = packed ?
new PackedInternalDoubleHistogram(instanceId, numberOfSignificantValueDigits) :
new InternalDoubleHistogram(instanceId, numberOfSignificantValueDigits);
inactiveHistogram = null;
activeHistogram.setStartTimeStamp(System.currentTimeMillis());
}
/**
* Construct an auto-resizing {@link SingleWriterDoubleRecorder} using a precision stated as a
* number of significant decimal digits.
*
* @param numberOfSignificantValueDigits Specifies the precision to use. This is the number of significant
* decimal digits to which the histogram will maintain value resolution
* and separation. Must be a non-negative integer between 0 and 5.
*/
public SingleWriterDoubleRecorder(final int numberOfSignificantValueDigits) {
this(numberOfSignificantValueDigits, false);
}
/**
* Construct a {@link SingleWriterDoubleRecorder} dynamic range of values to cover and a number
* of significant decimal digits.
*
* @param highestToLowestValueRatio specifies the dynamic range to use (as a ratio)
* @param numberOfSignificantValueDigits Specifies the precision to use. This is the number of significant
* decimal digits to which the histogram will maintain value resolution
* and separation. Must be a non-negative integer between 0 and 5.
*/
public SingleWriterDoubleRecorder(final long highestToLowestValueRatio,
final int numberOfSignificantValueDigits) {
activeHistogram = new InternalDoubleHistogram(
instanceId, highestToLowestValueRatio, numberOfSignificantValueDigits);
inactiveHistogram = null;
activeHistogram.setStartTimeStamp(System.currentTimeMillis());
}
/**
* Record a value
* @param value the value to record
* @throws ArrayIndexOutOfBoundsException (may throw) if value is exceeds highestTrackableValue
*/
public void recordValue(final double value) {
long criticalValueAtEnter = recordingPhaser.writerCriticalSectionEnter();
try {
activeHistogram.recordValue(value);
} finally {
recordingPhaser.writerCriticalSectionExit(criticalValueAtEnter);
}
}
/**
* Record a value in the histogram (adding to the value's current count)
*
* @param value The value to be recorded
* @param count The number of occurrences of this value to record
* @throws ArrayIndexOutOfBoundsException (may throw) if value is exceeds highestTrackableValue
*/
public void recordValueWithCount(final double value, final long count) throws ArrayIndexOutOfBoundsException {
long criticalValueAtEnter = recordingPhaser.writerCriticalSectionEnter();
try {
activeHistogram.recordValueWithCount(value, count);
} finally {
recordingPhaser.writerCriticalSectionExit(criticalValueAtEnter);
}
}
/**
* Record a value
* <p>
* To compensate for the loss of sampled values when a recorded value is larger than the expected
* interval between value samples, Histogram will auto-generate an additional series of decreasingly-smaller
* (down to the expectedIntervalBetweenValueSamples) value records.
* <p>
* See related notes {@link org.HdrHistogram.DoubleHistogram#recordValueWithExpectedInterval(double, double)}
* for more explanations about coordinated omission and expected interval correction.
* *
* @param value The value to record
* @param expectedIntervalBetweenValueSamples If expectedIntervalBetweenValueSamples is larger than 0, add
* auto-generated value records as appropriate if value is larger
* than expectedIntervalBetweenValueSamples
* @throws ArrayIndexOutOfBoundsException (may throw) if value is exceeds highestTrackableValue
*/
public void recordValueWithExpectedInterval(final double value, final double expectedIntervalBetweenValueSamples)
throws ArrayIndexOutOfBoundsException {<FILL_FUNCTION_BODY>}
@Override
public synchronized DoubleHistogram getIntervalHistogram() {
return getIntervalHistogram(null);
}
@Override
public synchronized DoubleHistogram getIntervalHistogram(DoubleHistogram histogramToRecycle) {
return getIntervalHistogram(histogramToRecycle, true);
}
@Override
public synchronized DoubleHistogram getIntervalHistogram(DoubleHistogram histogramToRecycle,
boolean enforceContainingInstance) {
// Verify that replacement histogram can validly be used as an inactive histogram replacement:
validateFitAsReplacementHistogram(histogramToRecycle, enforceContainingInstance);
inactiveHistogram = histogramToRecycle;
performIntervalSample();
DoubleHistogram sampledHistogram = inactiveHistogram;
inactiveHistogram = null; // Once we expose the sample, we can't reuse it internally until it is recycled
return sampledHistogram;
}
@Override
public synchronized void getIntervalHistogramInto(DoubleHistogram targetHistogram) {
performIntervalSample();
inactiveHistogram.copyInto(targetHistogram);
}
/**
* Reset any value counts accumulated thus far.
*/
public synchronized void reset() {
// the currently inactive histogram is reset each time we flip. So flipping twice resets both:
performIntervalSample();
performIntervalSample();
}
private void performIntervalSample() {
try {
recordingPhaser.readerLock();
// Make sure we have an inactive version to flip in:
if (inactiveHistogram == null) {
if (activeHistogram instanceof InternalDoubleHistogram) {
inactiveHistogram = new InternalDoubleHistogram((InternalDoubleHistogram) activeHistogram);
} else if (activeHistogram instanceof PackedInternalDoubleHistogram) {
inactiveHistogram = new PackedInternalDoubleHistogram(
instanceId, activeHistogram.getNumberOfSignificantValueDigits());
} else {
throw new IllegalStateException("Unexpected internal histogram type for activeHistogram");
}
}
inactiveHistogram.reset();
// Swap active and inactive histograms:
final DoubleHistogram tempHistogram = inactiveHistogram;
inactiveHistogram = activeHistogram;
activeHistogram = tempHistogram;
// Mark end time of previous interval and start time of new one:
long now = System.currentTimeMillis();
activeHistogram.setStartTimeStamp(now);
inactiveHistogram.setEndTimeStamp(now);
// Make sure we are not in the middle of recording a value on the previously active histogram:
// Flip phase to make sure no recordings that were in flight pre-flip are still active:
recordingPhaser.flipPhase(500000L /* yield in 0.5 msec units if needed */);
} finally {
recordingPhaser.readerUnlock();
}
}
private class InternalDoubleHistogram extends DoubleHistogram {
private final long containingInstanceId;
private InternalDoubleHistogram(long id, int numberOfSignificantValueDigits) {
super(numberOfSignificantValueDigits);
this.containingInstanceId = id;
}
private InternalDoubleHistogram(long id,
long highestToLowestValueRatio,
int numberOfSignificantValueDigits) {
super(highestToLowestValueRatio, numberOfSignificantValueDigits);
this.containingInstanceId = id;
}
private InternalDoubleHistogram(InternalDoubleHistogram source) {
super(source);
this.containingInstanceId = source.containingInstanceId;
}
}
private class PackedInternalDoubleHistogram extends PackedDoubleHistogram {
private final long containingInstanceId;
private PackedInternalDoubleHistogram(long id, int numberOfSignificantValueDigits) {
super(numberOfSignificantValueDigits);
this.containingInstanceId = id;
}
}
private void validateFitAsReplacementHistogram(DoubleHistogram replacementHistogram,
boolean enforceContainingInstance) {
boolean bad = true;
if (replacementHistogram == null) {
bad = false;
} else if ((replacementHistogram instanceof InternalDoubleHistogram)
&&
((!enforceContainingInstance) ||
(((InternalDoubleHistogram) replacementHistogram).containingInstanceId ==
((InternalDoubleHistogram)activeHistogram).containingInstanceId)
)) {
bad = false;
} else if ((replacementHistogram instanceof PackedInternalDoubleHistogram)
&&
((!enforceContainingInstance) ||
(((PackedInternalDoubleHistogram) replacementHistogram).containingInstanceId ==
((PackedInternalDoubleHistogram)activeHistogram).containingInstanceId)
)) {
bad = false;
}
if (bad) {
throw new IllegalArgumentException("replacement histogram must have been obtained via a previous " +
"getIntervalHistogram() call from this " + this.getClass().getName() +" instance");
}
}
} |
long criticalValueAtEnter = recordingPhaser.writerCriticalSectionEnter();
try {
activeHistogram.recordValueWithExpectedInterval(value, expectedIntervalBetweenValueSamples);
} finally {
recordingPhaser.writerCriticalSectionExit(criticalValueAtEnter);
}
|
HdrHistogram_HdrHistogram | HdrHistogram/src/main/java/org/HdrHistogram/SingleWriterDoubleRecorder.java | SingleWriterDoubleRecorder | getIntervalHistogram | class SingleWriterDoubleRecorder implements DoubleValueRecorder, IntervalHistogramProvider<DoubleHistogram> {
private static AtomicLong instanceIdSequencer = new AtomicLong(1);
private final long instanceId = instanceIdSequencer.getAndIncrement();
private final WriterReaderPhaser recordingPhaser = new WriterReaderPhaser();
private volatile DoubleHistogram activeHistogram;
private DoubleHistogram inactiveHistogram;
/**
* Construct an auto-resizing {@link SingleWriterDoubleRecorder} using a precision stated as a
* number of significant decimal digits.
* <p>
* Depending on the valuer of the <b><code>packed</code></b> parameter {@link SingleWriterDoubleRecorder} can
* be configured to track value counts in a packed internal representation optimized for typical histogram
* recoded values are sparse in the value range and tend to be incremented in small unit counts. This packed
* representation tends to require significantly smaller amounts of storage when compared to unpacked
* representations, but can incur additional recording cost due to resizing and repacking operations that may
* occur as previously unrecorded values are encountered.
*
* @param numberOfSignificantValueDigits Specifies the precision to use. This is the number of significant
* decimal digits to which the histogram will maintain value resolution
* and separation. Must be a non-negative integer between 0 and 5.
* @param packed Specifies whether the recorder will uses a packed internal representation or not.
*/
public SingleWriterDoubleRecorder(final int numberOfSignificantValueDigits, final boolean packed) {
activeHistogram = packed ?
new PackedInternalDoubleHistogram(instanceId, numberOfSignificantValueDigits) :
new InternalDoubleHistogram(instanceId, numberOfSignificantValueDigits);
inactiveHistogram = null;
activeHistogram.setStartTimeStamp(System.currentTimeMillis());
}
/**
* Construct an auto-resizing {@link SingleWriterDoubleRecorder} using a precision stated as a
* number of significant decimal digits.
*
* @param numberOfSignificantValueDigits Specifies the precision to use. This is the number of significant
* decimal digits to which the histogram will maintain value resolution
* and separation. Must be a non-negative integer between 0 and 5.
*/
public SingleWriterDoubleRecorder(final int numberOfSignificantValueDigits) {
this(numberOfSignificantValueDigits, false);
}
/**
* Construct a {@link SingleWriterDoubleRecorder} dynamic range of values to cover and a number
* of significant decimal digits.
*
* @param highestToLowestValueRatio specifies the dynamic range to use (as a ratio)
* @param numberOfSignificantValueDigits Specifies the precision to use. This is the number of significant
* decimal digits to which the histogram will maintain value resolution
* and separation. Must be a non-negative integer between 0 and 5.
*/
public SingleWriterDoubleRecorder(final long highestToLowestValueRatio,
final int numberOfSignificantValueDigits) {
activeHistogram = new InternalDoubleHistogram(
instanceId, highestToLowestValueRatio, numberOfSignificantValueDigits);
inactiveHistogram = null;
activeHistogram.setStartTimeStamp(System.currentTimeMillis());
}
/**
* Record a value
* @param value the value to record
* @throws ArrayIndexOutOfBoundsException (may throw) if value is exceeds highestTrackableValue
*/
public void recordValue(final double value) {
long criticalValueAtEnter = recordingPhaser.writerCriticalSectionEnter();
try {
activeHistogram.recordValue(value);
} finally {
recordingPhaser.writerCriticalSectionExit(criticalValueAtEnter);
}
}
/**
* Record a value in the histogram (adding to the value's current count)
*
* @param value The value to be recorded
* @param count The number of occurrences of this value to record
* @throws ArrayIndexOutOfBoundsException (may throw) if value is exceeds highestTrackableValue
*/
public void recordValueWithCount(final double value, final long count) throws ArrayIndexOutOfBoundsException {
long criticalValueAtEnter = recordingPhaser.writerCriticalSectionEnter();
try {
activeHistogram.recordValueWithCount(value, count);
} finally {
recordingPhaser.writerCriticalSectionExit(criticalValueAtEnter);
}
}
/**
* Record a value
* <p>
* To compensate for the loss of sampled values when a recorded value is larger than the expected
* interval between value samples, Histogram will auto-generate an additional series of decreasingly-smaller
* (down to the expectedIntervalBetweenValueSamples) value records.
* <p>
* See related notes {@link org.HdrHistogram.DoubleHistogram#recordValueWithExpectedInterval(double, double)}
* for more explanations about coordinated omission and expected interval correction.
* *
* @param value The value to record
* @param expectedIntervalBetweenValueSamples If expectedIntervalBetweenValueSamples is larger than 0, add
* auto-generated value records as appropriate if value is larger
* than expectedIntervalBetweenValueSamples
* @throws ArrayIndexOutOfBoundsException (may throw) if value is exceeds highestTrackableValue
*/
public void recordValueWithExpectedInterval(final double value, final double expectedIntervalBetweenValueSamples)
throws ArrayIndexOutOfBoundsException {
long criticalValueAtEnter = recordingPhaser.writerCriticalSectionEnter();
try {
activeHistogram.recordValueWithExpectedInterval(value, expectedIntervalBetweenValueSamples);
} finally {
recordingPhaser.writerCriticalSectionExit(criticalValueAtEnter);
}
}
@Override
public synchronized DoubleHistogram getIntervalHistogram() {<FILL_FUNCTION_BODY>}
@Override
public synchronized DoubleHistogram getIntervalHistogram(DoubleHistogram histogramToRecycle) {
return getIntervalHistogram(histogramToRecycle, true);
}
@Override
public synchronized DoubleHistogram getIntervalHistogram(DoubleHistogram histogramToRecycle,
boolean enforceContainingInstance) {
// Verify that replacement histogram can validly be used as an inactive histogram replacement:
validateFitAsReplacementHistogram(histogramToRecycle, enforceContainingInstance);
inactiveHistogram = histogramToRecycle;
performIntervalSample();
DoubleHistogram sampledHistogram = inactiveHistogram;
inactiveHistogram = null; // Once we expose the sample, we can't reuse it internally until it is recycled
return sampledHistogram;
}
@Override
public synchronized void getIntervalHistogramInto(DoubleHistogram targetHistogram) {
performIntervalSample();
inactiveHistogram.copyInto(targetHistogram);
}
/**
* Reset any value counts accumulated thus far.
*/
public synchronized void reset() {
// the currently inactive histogram is reset each time we flip. So flipping twice resets both:
performIntervalSample();
performIntervalSample();
}
private void performIntervalSample() {
try {
recordingPhaser.readerLock();
// Make sure we have an inactive version to flip in:
if (inactiveHistogram == null) {
if (activeHistogram instanceof InternalDoubleHistogram) {
inactiveHistogram = new InternalDoubleHistogram((InternalDoubleHistogram) activeHistogram);
} else if (activeHistogram instanceof PackedInternalDoubleHistogram) {
inactiveHistogram = new PackedInternalDoubleHistogram(
instanceId, activeHistogram.getNumberOfSignificantValueDigits());
} else {
throw new IllegalStateException("Unexpected internal histogram type for activeHistogram");
}
}
inactiveHistogram.reset();
// Swap active and inactive histograms:
final DoubleHistogram tempHistogram = inactiveHistogram;
inactiveHistogram = activeHistogram;
activeHistogram = tempHistogram;
// Mark end time of previous interval and start time of new one:
long now = System.currentTimeMillis();
activeHistogram.setStartTimeStamp(now);
inactiveHistogram.setEndTimeStamp(now);
// Make sure we are not in the middle of recording a value on the previously active histogram:
// Flip phase to make sure no recordings that were in flight pre-flip are still active:
recordingPhaser.flipPhase(500000L /* yield in 0.5 msec units if needed */);
} finally {
recordingPhaser.readerUnlock();
}
}
private class InternalDoubleHistogram extends DoubleHistogram {
private final long containingInstanceId;
private InternalDoubleHistogram(long id, int numberOfSignificantValueDigits) {
super(numberOfSignificantValueDigits);
this.containingInstanceId = id;
}
private InternalDoubleHistogram(long id,
long highestToLowestValueRatio,
int numberOfSignificantValueDigits) {
super(highestToLowestValueRatio, numberOfSignificantValueDigits);
this.containingInstanceId = id;
}
private InternalDoubleHistogram(InternalDoubleHistogram source) {
super(source);
this.containingInstanceId = source.containingInstanceId;
}
}
private class PackedInternalDoubleHistogram extends PackedDoubleHistogram {
private final long containingInstanceId;
private PackedInternalDoubleHistogram(long id, int numberOfSignificantValueDigits) {
super(numberOfSignificantValueDigits);
this.containingInstanceId = id;
}
}
private void validateFitAsReplacementHistogram(DoubleHistogram replacementHistogram,
boolean enforceContainingInstance) {
boolean bad = true;
if (replacementHistogram == null) {
bad = false;
} else if ((replacementHistogram instanceof InternalDoubleHistogram)
&&
((!enforceContainingInstance) ||
(((InternalDoubleHistogram) replacementHistogram).containingInstanceId ==
((InternalDoubleHistogram)activeHistogram).containingInstanceId)
)) {
bad = false;
} else if ((replacementHistogram instanceof PackedInternalDoubleHistogram)
&&
((!enforceContainingInstance) ||
(((PackedInternalDoubleHistogram) replacementHistogram).containingInstanceId ==
((PackedInternalDoubleHistogram)activeHistogram).containingInstanceId)
)) {
bad = false;
}
if (bad) {
throw new IllegalArgumentException("replacement histogram must have been obtained via a previous " +
"getIntervalHistogram() call from this " + this.getClass().getName() +" instance");
}
}
} |
return getIntervalHistogram(null);
|
HdrHistogram_HdrHistogram | HdrHistogram/src/main/java/org/HdrHistogram/SingleWriterDoubleRecorder.java | SingleWriterDoubleRecorder | getIntervalHistogram | class SingleWriterDoubleRecorder implements DoubleValueRecorder, IntervalHistogramProvider<DoubleHistogram> {
private static AtomicLong instanceIdSequencer = new AtomicLong(1);
private final long instanceId = instanceIdSequencer.getAndIncrement();
private final WriterReaderPhaser recordingPhaser = new WriterReaderPhaser();
private volatile DoubleHistogram activeHistogram;
private DoubleHistogram inactiveHistogram;
/**
* Construct an auto-resizing {@link SingleWriterDoubleRecorder} using a precision stated as a
* number of significant decimal digits.
* <p>
* Depending on the valuer of the <b><code>packed</code></b> parameter {@link SingleWriterDoubleRecorder} can
* be configured to track value counts in a packed internal representation optimized for typical histogram
* recoded values are sparse in the value range and tend to be incremented in small unit counts. This packed
* representation tends to require significantly smaller amounts of storage when compared to unpacked
* representations, but can incur additional recording cost due to resizing and repacking operations that may
* occur as previously unrecorded values are encountered.
*
* @param numberOfSignificantValueDigits Specifies the precision to use. This is the number of significant
* decimal digits to which the histogram will maintain value resolution
* and separation. Must be a non-negative integer between 0 and 5.
* @param packed Specifies whether the recorder will uses a packed internal representation or not.
*/
public SingleWriterDoubleRecorder(final int numberOfSignificantValueDigits, final boolean packed) {
activeHistogram = packed ?
new PackedInternalDoubleHistogram(instanceId, numberOfSignificantValueDigits) :
new InternalDoubleHistogram(instanceId, numberOfSignificantValueDigits);
inactiveHistogram = null;
activeHistogram.setStartTimeStamp(System.currentTimeMillis());
}
/**
* Construct an auto-resizing {@link SingleWriterDoubleRecorder} using a precision stated as a
* number of significant decimal digits.
*
* @param numberOfSignificantValueDigits Specifies the precision to use. This is the number of significant
* decimal digits to which the histogram will maintain value resolution
* and separation. Must be a non-negative integer between 0 and 5.
*/
public SingleWriterDoubleRecorder(final int numberOfSignificantValueDigits) {
this(numberOfSignificantValueDigits, false);
}
/**
* Construct a {@link SingleWriterDoubleRecorder} dynamic range of values to cover and a number
* of significant decimal digits.
*
* @param highestToLowestValueRatio specifies the dynamic range to use (as a ratio)
* @param numberOfSignificantValueDigits Specifies the precision to use. This is the number of significant
* decimal digits to which the histogram will maintain value resolution
* and separation. Must be a non-negative integer between 0 and 5.
*/
public SingleWriterDoubleRecorder(final long highestToLowestValueRatio,
final int numberOfSignificantValueDigits) {
activeHistogram = new InternalDoubleHistogram(
instanceId, highestToLowestValueRatio, numberOfSignificantValueDigits);
inactiveHistogram = null;
activeHistogram.setStartTimeStamp(System.currentTimeMillis());
}
/**
* Record a value
* @param value the value to record
* @throws ArrayIndexOutOfBoundsException (may throw) if value is exceeds highestTrackableValue
*/
public void recordValue(final double value) {
long criticalValueAtEnter = recordingPhaser.writerCriticalSectionEnter();
try {
activeHistogram.recordValue(value);
} finally {
recordingPhaser.writerCriticalSectionExit(criticalValueAtEnter);
}
}
/**
* Record a value in the histogram (adding to the value's current count)
*
* @param value The value to be recorded
* @param count The number of occurrences of this value to record
* @throws ArrayIndexOutOfBoundsException (may throw) if value is exceeds highestTrackableValue
*/
public void recordValueWithCount(final double value, final long count) throws ArrayIndexOutOfBoundsException {
long criticalValueAtEnter = recordingPhaser.writerCriticalSectionEnter();
try {
activeHistogram.recordValueWithCount(value, count);
} finally {
recordingPhaser.writerCriticalSectionExit(criticalValueAtEnter);
}
}
/**
* Record a value
* <p>
* To compensate for the loss of sampled values when a recorded value is larger than the expected
* interval between value samples, Histogram will auto-generate an additional series of decreasingly-smaller
* (down to the expectedIntervalBetweenValueSamples) value records.
* <p>
* See related notes {@link org.HdrHistogram.DoubleHistogram#recordValueWithExpectedInterval(double, double)}
* for more explanations about coordinated omission and expected interval correction.
* *
* @param value The value to record
* @param expectedIntervalBetweenValueSamples If expectedIntervalBetweenValueSamples is larger than 0, add
* auto-generated value records as appropriate if value is larger
* than expectedIntervalBetweenValueSamples
* @throws ArrayIndexOutOfBoundsException (may throw) if value is exceeds highestTrackableValue
*/
public void recordValueWithExpectedInterval(final double value, final double expectedIntervalBetweenValueSamples)
throws ArrayIndexOutOfBoundsException {
long criticalValueAtEnter = recordingPhaser.writerCriticalSectionEnter();
try {
activeHistogram.recordValueWithExpectedInterval(value, expectedIntervalBetweenValueSamples);
} finally {
recordingPhaser.writerCriticalSectionExit(criticalValueAtEnter);
}
}
@Override
public synchronized DoubleHistogram getIntervalHistogram() {
return getIntervalHistogram(null);
}
@Override
public synchronized DoubleHistogram getIntervalHistogram(DoubleHistogram histogramToRecycle) {<FILL_FUNCTION_BODY>}
@Override
public synchronized DoubleHistogram getIntervalHistogram(DoubleHistogram histogramToRecycle,
boolean enforceContainingInstance) {
// Verify that replacement histogram can validly be used as an inactive histogram replacement:
validateFitAsReplacementHistogram(histogramToRecycle, enforceContainingInstance);
inactiveHistogram = histogramToRecycle;
performIntervalSample();
DoubleHistogram sampledHistogram = inactiveHistogram;
inactiveHistogram = null; // Once we expose the sample, we can't reuse it internally until it is recycled
return sampledHistogram;
}
@Override
public synchronized void getIntervalHistogramInto(DoubleHistogram targetHistogram) {
performIntervalSample();
inactiveHistogram.copyInto(targetHistogram);
}
/**
* Reset any value counts accumulated thus far.
*/
public synchronized void reset() {
// the currently inactive histogram is reset each time we flip. So flipping twice resets both:
performIntervalSample();
performIntervalSample();
}
private void performIntervalSample() {
try {
recordingPhaser.readerLock();
// Make sure we have an inactive version to flip in:
if (inactiveHistogram == null) {
if (activeHistogram instanceof InternalDoubleHistogram) {
inactiveHistogram = new InternalDoubleHistogram((InternalDoubleHistogram) activeHistogram);
} else if (activeHistogram instanceof PackedInternalDoubleHistogram) {
inactiveHistogram = new PackedInternalDoubleHistogram(
instanceId, activeHistogram.getNumberOfSignificantValueDigits());
} else {
throw new IllegalStateException("Unexpected internal histogram type for activeHistogram");
}
}
inactiveHistogram.reset();
// Swap active and inactive histograms:
final DoubleHistogram tempHistogram = inactiveHistogram;
inactiveHistogram = activeHistogram;
activeHistogram = tempHistogram;
// Mark end time of previous interval and start time of new one:
long now = System.currentTimeMillis();
activeHistogram.setStartTimeStamp(now);
inactiveHistogram.setEndTimeStamp(now);
// Make sure we are not in the middle of recording a value on the previously active histogram:
// Flip phase to make sure no recordings that were in flight pre-flip are still active:
recordingPhaser.flipPhase(500000L /* yield in 0.5 msec units if needed */);
} finally {
recordingPhaser.readerUnlock();
}
}
private class InternalDoubleHistogram extends DoubleHistogram {
private final long containingInstanceId;
private InternalDoubleHistogram(long id, int numberOfSignificantValueDigits) {
super(numberOfSignificantValueDigits);
this.containingInstanceId = id;
}
private InternalDoubleHistogram(long id,
long highestToLowestValueRatio,
int numberOfSignificantValueDigits) {
super(highestToLowestValueRatio, numberOfSignificantValueDigits);
this.containingInstanceId = id;
}
private InternalDoubleHistogram(InternalDoubleHistogram source) {
super(source);
this.containingInstanceId = source.containingInstanceId;
}
}
private class PackedInternalDoubleHistogram extends PackedDoubleHistogram {
private final long containingInstanceId;
private PackedInternalDoubleHistogram(long id, int numberOfSignificantValueDigits) {
super(numberOfSignificantValueDigits);
this.containingInstanceId = id;
}
}
private void validateFitAsReplacementHistogram(DoubleHistogram replacementHistogram,
boolean enforceContainingInstance) {
boolean bad = true;
if (replacementHistogram == null) {
bad = false;
} else if ((replacementHistogram instanceof InternalDoubleHistogram)
&&
((!enforceContainingInstance) ||
(((InternalDoubleHistogram) replacementHistogram).containingInstanceId ==
((InternalDoubleHistogram)activeHistogram).containingInstanceId)
)) {
bad = false;
} else if ((replacementHistogram instanceof PackedInternalDoubleHistogram)
&&
((!enforceContainingInstance) ||
(((PackedInternalDoubleHistogram) replacementHistogram).containingInstanceId ==
((PackedInternalDoubleHistogram)activeHistogram).containingInstanceId)
)) {
bad = false;
}
if (bad) {
throw new IllegalArgumentException("replacement histogram must have been obtained via a previous " +
"getIntervalHistogram() call from this " + this.getClass().getName() +" instance");
}
}
} |
return getIntervalHistogram(histogramToRecycle, true);
|
HdrHistogram_HdrHistogram | HdrHistogram/src/main/java/org/HdrHistogram/SingleWriterDoubleRecorder.java | SingleWriterDoubleRecorder | getIntervalHistogram | class SingleWriterDoubleRecorder implements DoubleValueRecorder, IntervalHistogramProvider<DoubleHistogram> {
private static AtomicLong instanceIdSequencer = new AtomicLong(1);
private final long instanceId = instanceIdSequencer.getAndIncrement();
private final WriterReaderPhaser recordingPhaser = new WriterReaderPhaser();
private volatile DoubleHistogram activeHistogram;
private DoubleHistogram inactiveHistogram;
/**
* Construct an auto-resizing {@link SingleWriterDoubleRecorder} using a precision stated as a
* number of significant decimal digits.
* <p>
* Depending on the valuer of the <b><code>packed</code></b> parameter {@link SingleWriterDoubleRecorder} can
* be configured to track value counts in a packed internal representation optimized for typical histogram
* recoded values are sparse in the value range and tend to be incremented in small unit counts. This packed
* representation tends to require significantly smaller amounts of storage when compared to unpacked
* representations, but can incur additional recording cost due to resizing and repacking operations that may
* occur as previously unrecorded values are encountered.
*
* @param numberOfSignificantValueDigits Specifies the precision to use. This is the number of significant
* decimal digits to which the histogram will maintain value resolution
* and separation. Must be a non-negative integer between 0 and 5.
* @param packed Specifies whether the recorder will uses a packed internal representation or not.
*/
public SingleWriterDoubleRecorder(final int numberOfSignificantValueDigits, final boolean packed) {
activeHistogram = packed ?
new PackedInternalDoubleHistogram(instanceId, numberOfSignificantValueDigits) :
new InternalDoubleHistogram(instanceId, numberOfSignificantValueDigits);
inactiveHistogram = null;
activeHistogram.setStartTimeStamp(System.currentTimeMillis());
}
/**
* Construct an auto-resizing {@link SingleWriterDoubleRecorder} using a precision stated as a
* number of significant decimal digits.
*
* @param numberOfSignificantValueDigits Specifies the precision to use. This is the number of significant
* decimal digits to which the histogram will maintain value resolution
* and separation. Must be a non-negative integer between 0 and 5.
*/
public SingleWriterDoubleRecorder(final int numberOfSignificantValueDigits) {
this(numberOfSignificantValueDigits, false);
}
/**
* Construct a {@link SingleWriterDoubleRecorder} dynamic range of values to cover and a number
* of significant decimal digits.
*
* @param highestToLowestValueRatio specifies the dynamic range to use (as a ratio)
* @param numberOfSignificantValueDigits Specifies the precision to use. This is the number of significant
* decimal digits to which the histogram will maintain value resolution
* and separation. Must be a non-negative integer between 0 and 5.
*/
public SingleWriterDoubleRecorder(final long highestToLowestValueRatio,
final int numberOfSignificantValueDigits) {
activeHistogram = new InternalDoubleHistogram(
instanceId, highestToLowestValueRatio, numberOfSignificantValueDigits);
inactiveHistogram = null;
activeHistogram.setStartTimeStamp(System.currentTimeMillis());
}
/**
* Record a value
* @param value the value to record
* @throws ArrayIndexOutOfBoundsException (may throw) if value is exceeds highestTrackableValue
*/
public void recordValue(final double value) {
long criticalValueAtEnter = recordingPhaser.writerCriticalSectionEnter();
try {
activeHistogram.recordValue(value);
} finally {
recordingPhaser.writerCriticalSectionExit(criticalValueAtEnter);
}
}
/**
* Record a value in the histogram (adding to the value's current count)
*
* @param value The value to be recorded
* @param count The number of occurrences of this value to record
* @throws ArrayIndexOutOfBoundsException (may throw) if value is exceeds highestTrackableValue
*/
public void recordValueWithCount(final double value, final long count) throws ArrayIndexOutOfBoundsException {
long criticalValueAtEnter = recordingPhaser.writerCriticalSectionEnter();
try {
activeHistogram.recordValueWithCount(value, count);
} finally {
recordingPhaser.writerCriticalSectionExit(criticalValueAtEnter);
}
}
/**
* Record a value
* <p>
* To compensate for the loss of sampled values when a recorded value is larger than the expected
* interval between value samples, Histogram will auto-generate an additional series of decreasingly-smaller
* (down to the expectedIntervalBetweenValueSamples) value records.
* <p>
* See related notes {@link org.HdrHistogram.DoubleHistogram#recordValueWithExpectedInterval(double, double)}
* for more explanations about coordinated omission and expected interval correction.
* *
* @param value The value to record
* @param expectedIntervalBetweenValueSamples If expectedIntervalBetweenValueSamples is larger than 0, add
* auto-generated value records as appropriate if value is larger
* than expectedIntervalBetweenValueSamples
* @throws ArrayIndexOutOfBoundsException (may throw) if value is exceeds highestTrackableValue
*/
public void recordValueWithExpectedInterval(final double value, final double expectedIntervalBetweenValueSamples)
throws ArrayIndexOutOfBoundsException {
long criticalValueAtEnter = recordingPhaser.writerCriticalSectionEnter();
try {
activeHistogram.recordValueWithExpectedInterval(value, expectedIntervalBetweenValueSamples);
} finally {
recordingPhaser.writerCriticalSectionExit(criticalValueAtEnter);
}
}
@Override
public synchronized DoubleHistogram getIntervalHistogram() {
return getIntervalHistogram(null);
}
@Override
public synchronized DoubleHistogram getIntervalHistogram(DoubleHistogram histogramToRecycle) {
return getIntervalHistogram(histogramToRecycle, true);
}
@Override
public synchronized DoubleHistogram getIntervalHistogram(DoubleHistogram histogramToRecycle,
boolean enforceContainingInstance) {<FILL_FUNCTION_BODY>}
@Override
public synchronized void getIntervalHistogramInto(DoubleHistogram targetHistogram) {
performIntervalSample();
inactiveHistogram.copyInto(targetHistogram);
}
/**
* Reset any value counts accumulated thus far.
*/
public synchronized void reset() {
// the currently inactive histogram is reset each time we flip. So flipping twice resets both:
performIntervalSample();
performIntervalSample();
}
private void performIntervalSample() {
try {
recordingPhaser.readerLock();
// Make sure we have an inactive version to flip in:
if (inactiveHistogram == null) {
if (activeHistogram instanceof InternalDoubleHistogram) {
inactiveHistogram = new InternalDoubleHistogram((InternalDoubleHistogram) activeHistogram);
} else if (activeHistogram instanceof PackedInternalDoubleHistogram) {
inactiveHistogram = new PackedInternalDoubleHistogram(
instanceId, activeHistogram.getNumberOfSignificantValueDigits());
} else {
throw new IllegalStateException("Unexpected internal histogram type for activeHistogram");
}
}
inactiveHistogram.reset();
// Swap active and inactive histograms:
final DoubleHistogram tempHistogram = inactiveHistogram;
inactiveHistogram = activeHistogram;
activeHistogram = tempHistogram;
// Mark end time of previous interval and start time of new one:
long now = System.currentTimeMillis();
activeHistogram.setStartTimeStamp(now);
inactiveHistogram.setEndTimeStamp(now);
// Make sure we are not in the middle of recording a value on the previously active histogram:
// Flip phase to make sure no recordings that were in flight pre-flip are still active:
recordingPhaser.flipPhase(500000L /* yield in 0.5 msec units if needed */);
} finally {
recordingPhaser.readerUnlock();
}
}
private class InternalDoubleHistogram extends DoubleHistogram {
private final long containingInstanceId;
private InternalDoubleHistogram(long id, int numberOfSignificantValueDigits) {
super(numberOfSignificantValueDigits);
this.containingInstanceId = id;
}
private InternalDoubleHistogram(long id,
long highestToLowestValueRatio,
int numberOfSignificantValueDigits) {
super(highestToLowestValueRatio, numberOfSignificantValueDigits);
this.containingInstanceId = id;
}
private InternalDoubleHistogram(InternalDoubleHistogram source) {
super(source);
this.containingInstanceId = source.containingInstanceId;
}
}
private class PackedInternalDoubleHistogram extends PackedDoubleHistogram {
private final long containingInstanceId;
private PackedInternalDoubleHistogram(long id, int numberOfSignificantValueDigits) {
super(numberOfSignificantValueDigits);
this.containingInstanceId = id;
}
}
private void validateFitAsReplacementHistogram(DoubleHistogram replacementHistogram,
boolean enforceContainingInstance) {
boolean bad = true;
if (replacementHistogram == null) {
bad = false;
} else if ((replacementHistogram instanceof InternalDoubleHistogram)
&&
((!enforceContainingInstance) ||
(((InternalDoubleHistogram) replacementHistogram).containingInstanceId ==
((InternalDoubleHistogram)activeHistogram).containingInstanceId)
)) {
bad = false;
} else if ((replacementHistogram instanceof PackedInternalDoubleHistogram)
&&
((!enforceContainingInstance) ||
(((PackedInternalDoubleHistogram) replacementHistogram).containingInstanceId ==
((PackedInternalDoubleHistogram)activeHistogram).containingInstanceId)
)) {
bad = false;
}
if (bad) {
throw new IllegalArgumentException("replacement histogram must have been obtained via a previous " +
"getIntervalHistogram() call from this " + this.getClass().getName() +" instance");
}
}
} |
// Verify that replacement histogram can validly be used as an inactive histogram replacement:
validateFitAsReplacementHistogram(histogramToRecycle, enforceContainingInstance);
inactiveHistogram = histogramToRecycle;
performIntervalSample();
DoubleHistogram sampledHistogram = inactiveHistogram;
inactiveHistogram = null; // Once we expose the sample, we can't reuse it internally until it is recycled
return sampledHistogram;
|
HdrHistogram_HdrHistogram | HdrHistogram/src/main/java/org/HdrHistogram/SingleWriterDoubleRecorder.java | SingleWriterDoubleRecorder | getIntervalHistogramInto | class SingleWriterDoubleRecorder implements DoubleValueRecorder, IntervalHistogramProvider<DoubleHistogram> {
private static AtomicLong instanceIdSequencer = new AtomicLong(1);
private final long instanceId = instanceIdSequencer.getAndIncrement();
private final WriterReaderPhaser recordingPhaser = new WriterReaderPhaser();
private volatile DoubleHistogram activeHistogram;
private DoubleHistogram inactiveHistogram;
/**
* Construct an auto-resizing {@link SingleWriterDoubleRecorder} using a precision stated as a
* number of significant decimal digits.
* <p>
* Depending on the valuer of the <b><code>packed</code></b> parameter {@link SingleWriterDoubleRecorder} can
* be configured to track value counts in a packed internal representation optimized for typical histogram
* recoded values are sparse in the value range and tend to be incremented in small unit counts. This packed
* representation tends to require significantly smaller amounts of storage when compared to unpacked
* representations, but can incur additional recording cost due to resizing and repacking operations that may
* occur as previously unrecorded values are encountered.
*
* @param numberOfSignificantValueDigits Specifies the precision to use. This is the number of significant
* decimal digits to which the histogram will maintain value resolution
* and separation. Must be a non-negative integer between 0 and 5.
* @param packed Specifies whether the recorder will uses a packed internal representation or not.
*/
public SingleWriterDoubleRecorder(final int numberOfSignificantValueDigits, final boolean packed) {
activeHistogram = packed ?
new PackedInternalDoubleHistogram(instanceId, numberOfSignificantValueDigits) :
new InternalDoubleHistogram(instanceId, numberOfSignificantValueDigits);
inactiveHistogram = null;
activeHistogram.setStartTimeStamp(System.currentTimeMillis());
}
/**
* Construct an auto-resizing {@link SingleWriterDoubleRecorder} using a precision stated as a
* number of significant decimal digits.
*
* @param numberOfSignificantValueDigits Specifies the precision to use. This is the number of significant
* decimal digits to which the histogram will maintain value resolution
* and separation. Must be a non-negative integer between 0 and 5.
*/
public SingleWriterDoubleRecorder(final int numberOfSignificantValueDigits) {
this(numberOfSignificantValueDigits, false);
}
/**
* Construct a {@link SingleWriterDoubleRecorder} dynamic range of values to cover and a number
* of significant decimal digits.
*
* @param highestToLowestValueRatio specifies the dynamic range to use (as a ratio)
* @param numberOfSignificantValueDigits Specifies the precision to use. This is the number of significant
* decimal digits to which the histogram will maintain value resolution
* and separation. Must be a non-negative integer between 0 and 5.
*/
public SingleWriterDoubleRecorder(final long highestToLowestValueRatio,
final int numberOfSignificantValueDigits) {
activeHistogram = new InternalDoubleHistogram(
instanceId, highestToLowestValueRatio, numberOfSignificantValueDigits);
inactiveHistogram = null;
activeHistogram.setStartTimeStamp(System.currentTimeMillis());
}
/**
* Record a value
* @param value the value to record
* @throws ArrayIndexOutOfBoundsException (may throw) if value is exceeds highestTrackableValue
*/
public void recordValue(final double value) {
long criticalValueAtEnter = recordingPhaser.writerCriticalSectionEnter();
try {
activeHistogram.recordValue(value);
} finally {
recordingPhaser.writerCriticalSectionExit(criticalValueAtEnter);
}
}
/**
* Record a value in the histogram (adding to the value's current count)
*
* @param value The value to be recorded
* @param count The number of occurrences of this value to record
* @throws ArrayIndexOutOfBoundsException (may throw) if value is exceeds highestTrackableValue
*/
public void recordValueWithCount(final double value, final long count) throws ArrayIndexOutOfBoundsException {
long criticalValueAtEnter = recordingPhaser.writerCriticalSectionEnter();
try {
activeHistogram.recordValueWithCount(value, count);
} finally {
recordingPhaser.writerCriticalSectionExit(criticalValueAtEnter);
}
}
/**
* Record a value
* <p>
* To compensate for the loss of sampled values when a recorded value is larger than the expected
* interval between value samples, Histogram will auto-generate an additional series of decreasingly-smaller
* (down to the expectedIntervalBetweenValueSamples) value records.
* <p>
* See related notes {@link org.HdrHistogram.DoubleHistogram#recordValueWithExpectedInterval(double, double)}
* for more explanations about coordinated omission and expected interval correction.
* *
* @param value The value to record
* @param expectedIntervalBetweenValueSamples If expectedIntervalBetweenValueSamples is larger than 0, add
* auto-generated value records as appropriate if value is larger
* than expectedIntervalBetweenValueSamples
* @throws ArrayIndexOutOfBoundsException (may throw) if value is exceeds highestTrackableValue
*/
public void recordValueWithExpectedInterval(final double value, final double expectedIntervalBetweenValueSamples)
throws ArrayIndexOutOfBoundsException {
long criticalValueAtEnter = recordingPhaser.writerCriticalSectionEnter();
try {
activeHistogram.recordValueWithExpectedInterval(value, expectedIntervalBetweenValueSamples);
} finally {
recordingPhaser.writerCriticalSectionExit(criticalValueAtEnter);
}
}
@Override
public synchronized DoubleHistogram getIntervalHistogram() {
return getIntervalHistogram(null);
}
@Override
public synchronized DoubleHistogram getIntervalHistogram(DoubleHistogram histogramToRecycle) {
return getIntervalHistogram(histogramToRecycle, true);
}
@Override
public synchronized DoubleHistogram getIntervalHistogram(DoubleHistogram histogramToRecycle,
boolean enforceContainingInstance) {
// Verify that replacement histogram can validly be used as an inactive histogram replacement:
validateFitAsReplacementHistogram(histogramToRecycle, enforceContainingInstance);
inactiveHistogram = histogramToRecycle;
performIntervalSample();
DoubleHistogram sampledHistogram = inactiveHistogram;
inactiveHistogram = null; // Once we expose the sample, we can't reuse it internally until it is recycled
return sampledHistogram;
}
@Override
public synchronized void getIntervalHistogramInto(DoubleHistogram targetHistogram) {<FILL_FUNCTION_BODY>}
/**
* Reset any value counts accumulated thus far.
*/
public synchronized void reset() {
// the currently inactive histogram is reset each time we flip. So flipping twice resets both:
performIntervalSample();
performIntervalSample();
}
private void performIntervalSample() {
try {
recordingPhaser.readerLock();
// Make sure we have an inactive version to flip in:
if (inactiveHistogram == null) {
if (activeHistogram instanceof InternalDoubleHistogram) {
inactiveHistogram = new InternalDoubleHistogram((InternalDoubleHistogram) activeHistogram);
} else if (activeHistogram instanceof PackedInternalDoubleHistogram) {
inactiveHistogram = new PackedInternalDoubleHistogram(
instanceId, activeHistogram.getNumberOfSignificantValueDigits());
} else {
throw new IllegalStateException("Unexpected internal histogram type for activeHistogram");
}
}
inactiveHistogram.reset();
// Swap active and inactive histograms:
final DoubleHistogram tempHistogram = inactiveHistogram;
inactiveHistogram = activeHistogram;
activeHistogram = tempHistogram;
// Mark end time of previous interval and start time of new one:
long now = System.currentTimeMillis();
activeHistogram.setStartTimeStamp(now);
inactiveHistogram.setEndTimeStamp(now);
// Make sure we are not in the middle of recording a value on the previously active histogram:
// Flip phase to make sure no recordings that were in flight pre-flip are still active:
recordingPhaser.flipPhase(500000L /* yield in 0.5 msec units if needed */);
} finally {
recordingPhaser.readerUnlock();
}
}
private class InternalDoubleHistogram extends DoubleHistogram {
private final long containingInstanceId;
private InternalDoubleHistogram(long id, int numberOfSignificantValueDigits) {
super(numberOfSignificantValueDigits);
this.containingInstanceId = id;
}
private InternalDoubleHistogram(long id,
long highestToLowestValueRatio,
int numberOfSignificantValueDigits) {
super(highestToLowestValueRatio, numberOfSignificantValueDigits);
this.containingInstanceId = id;
}
private InternalDoubleHistogram(InternalDoubleHistogram source) {
super(source);
this.containingInstanceId = source.containingInstanceId;
}
}
private class PackedInternalDoubleHistogram extends PackedDoubleHistogram {
private final long containingInstanceId;
private PackedInternalDoubleHistogram(long id, int numberOfSignificantValueDigits) {
super(numberOfSignificantValueDigits);
this.containingInstanceId = id;
}
}
private void validateFitAsReplacementHistogram(DoubleHistogram replacementHistogram,
boolean enforceContainingInstance) {
boolean bad = true;
if (replacementHistogram == null) {
bad = false;
} else if ((replacementHistogram instanceof InternalDoubleHistogram)
&&
((!enforceContainingInstance) ||
(((InternalDoubleHistogram) replacementHistogram).containingInstanceId ==
((InternalDoubleHistogram)activeHistogram).containingInstanceId)
)) {
bad = false;
} else if ((replacementHistogram instanceof PackedInternalDoubleHistogram)
&&
((!enforceContainingInstance) ||
(((PackedInternalDoubleHistogram) replacementHistogram).containingInstanceId ==
((PackedInternalDoubleHistogram)activeHistogram).containingInstanceId)
)) {
bad = false;
}
if (bad) {
throw new IllegalArgumentException("replacement histogram must have been obtained via a previous " +
"getIntervalHistogram() call from this " + this.getClass().getName() +" instance");
}
}
} |
performIntervalSample();
inactiveHistogram.copyInto(targetHistogram);
|
HdrHistogram_HdrHistogram | HdrHistogram/src/main/java/org/HdrHistogram/SingleWriterDoubleRecorder.java | SingleWriterDoubleRecorder | reset | class SingleWriterDoubleRecorder implements DoubleValueRecorder, IntervalHistogramProvider<DoubleHistogram> {
private static AtomicLong instanceIdSequencer = new AtomicLong(1);
private final long instanceId = instanceIdSequencer.getAndIncrement();
private final WriterReaderPhaser recordingPhaser = new WriterReaderPhaser();
private volatile DoubleHistogram activeHistogram;
private DoubleHistogram inactiveHistogram;
/**
* Construct an auto-resizing {@link SingleWriterDoubleRecorder} using a precision stated as a
* number of significant decimal digits.
* <p>
* Depending on the valuer of the <b><code>packed</code></b> parameter {@link SingleWriterDoubleRecorder} can
* be configured to track value counts in a packed internal representation optimized for typical histogram
* recoded values are sparse in the value range and tend to be incremented in small unit counts. This packed
* representation tends to require significantly smaller amounts of storage when compared to unpacked
* representations, but can incur additional recording cost due to resizing and repacking operations that may
* occur as previously unrecorded values are encountered.
*
* @param numberOfSignificantValueDigits Specifies the precision to use. This is the number of significant
* decimal digits to which the histogram will maintain value resolution
* and separation. Must be a non-negative integer between 0 and 5.
* @param packed Specifies whether the recorder will uses a packed internal representation or not.
*/
public SingleWriterDoubleRecorder(final int numberOfSignificantValueDigits, final boolean packed) {
activeHistogram = packed ?
new PackedInternalDoubleHistogram(instanceId, numberOfSignificantValueDigits) :
new InternalDoubleHistogram(instanceId, numberOfSignificantValueDigits);
inactiveHistogram = null;
activeHistogram.setStartTimeStamp(System.currentTimeMillis());
}
/**
* Construct an auto-resizing {@link SingleWriterDoubleRecorder} using a precision stated as a
* number of significant decimal digits.
*
* @param numberOfSignificantValueDigits Specifies the precision to use. This is the number of significant
* decimal digits to which the histogram will maintain value resolution
* and separation. Must be a non-negative integer between 0 and 5.
*/
public SingleWriterDoubleRecorder(final int numberOfSignificantValueDigits) {
this(numberOfSignificantValueDigits, false);
}
/**
* Construct a {@link SingleWriterDoubleRecorder} dynamic range of values to cover and a number
* of significant decimal digits.
*
* @param highestToLowestValueRatio specifies the dynamic range to use (as a ratio)
* @param numberOfSignificantValueDigits Specifies the precision to use. This is the number of significant
* decimal digits to which the histogram will maintain value resolution
* and separation. Must be a non-negative integer between 0 and 5.
*/
public SingleWriterDoubleRecorder(final long highestToLowestValueRatio,
final int numberOfSignificantValueDigits) {
activeHistogram = new InternalDoubleHistogram(
instanceId, highestToLowestValueRatio, numberOfSignificantValueDigits);
inactiveHistogram = null;
activeHistogram.setStartTimeStamp(System.currentTimeMillis());
}
/**
* Record a value
* @param value the value to record
* @throws ArrayIndexOutOfBoundsException (may throw) if value is exceeds highestTrackableValue
*/
public void recordValue(final double value) {
long criticalValueAtEnter = recordingPhaser.writerCriticalSectionEnter();
try {
activeHistogram.recordValue(value);
} finally {
recordingPhaser.writerCriticalSectionExit(criticalValueAtEnter);
}
}
/**
* Record a value in the histogram (adding to the value's current count)
*
* @param value The value to be recorded
* @param count The number of occurrences of this value to record
* @throws ArrayIndexOutOfBoundsException (may throw) if value is exceeds highestTrackableValue
*/
public void recordValueWithCount(final double value, final long count) throws ArrayIndexOutOfBoundsException {
long criticalValueAtEnter = recordingPhaser.writerCriticalSectionEnter();
try {
activeHistogram.recordValueWithCount(value, count);
} finally {
recordingPhaser.writerCriticalSectionExit(criticalValueAtEnter);
}
}
/**
* Record a value
* <p>
* To compensate for the loss of sampled values when a recorded value is larger than the expected
* interval between value samples, Histogram will auto-generate an additional series of decreasingly-smaller
* (down to the expectedIntervalBetweenValueSamples) value records.
* <p>
* See related notes {@link org.HdrHistogram.DoubleHistogram#recordValueWithExpectedInterval(double, double)}
* for more explanations about coordinated omission and expected interval correction.
* *
* @param value The value to record
* @param expectedIntervalBetweenValueSamples If expectedIntervalBetweenValueSamples is larger than 0, add
* auto-generated value records as appropriate if value is larger
* than expectedIntervalBetweenValueSamples
* @throws ArrayIndexOutOfBoundsException (may throw) if value is exceeds highestTrackableValue
*/
public void recordValueWithExpectedInterval(final double value, final double expectedIntervalBetweenValueSamples)
throws ArrayIndexOutOfBoundsException {
long criticalValueAtEnter = recordingPhaser.writerCriticalSectionEnter();
try {
activeHistogram.recordValueWithExpectedInterval(value, expectedIntervalBetweenValueSamples);
} finally {
recordingPhaser.writerCriticalSectionExit(criticalValueAtEnter);
}
}
@Override
public synchronized DoubleHistogram getIntervalHistogram() {
return getIntervalHistogram(null);
}
@Override
public synchronized DoubleHistogram getIntervalHistogram(DoubleHistogram histogramToRecycle) {
return getIntervalHistogram(histogramToRecycle, true);
}
@Override
public synchronized DoubleHistogram getIntervalHistogram(DoubleHistogram histogramToRecycle,
boolean enforceContainingInstance) {
// Verify that replacement histogram can validly be used as an inactive histogram replacement:
validateFitAsReplacementHistogram(histogramToRecycle, enforceContainingInstance);
inactiveHistogram = histogramToRecycle;
performIntervalSample();
DoubleHistogram sampledHistogram = inactiveHistogram;
inactiveHistogram = null; // Once we expose the sample, we can't reuse it internally until it is recycled
return sampledHistogram;
}
@Override
public synchronized void getIntervalHistogramInto(DoubleHistogram targetHistogram) {
performIntervalSample();
inactiveHistogram.copyInto(targetHistogram);
}
/**
* Reset any value counts accumulated thus far.
*/
public synchronized void reset() {<FILL_FUNCTION_BODY>}
private void performIntervalSample() {
try {
recordingPhaser.readerLock();
// Make sure we have an inactive version to flip in:
if (inactiveHistogram == null) {
if (activeHistogram instanceof InternalDoubleHistogram) {
inactiveHistogram = new InternalDoubleHistogram((InternalDoubleHistogram) activeHistogram);
} else if (activeHistogram instanceof PackedInternalDoubleHistogram) {
inactiveHistogram = new PackedInternalDoubleHistogram(
instanceId, activeHistogram.getNumberOfSignificantValueDigits());
} else {
throw new IllegalStateException("Unexpected internal histogram type for activeHistogram");
}
}
inactiveHistogram.reset();
// Swap active and inactive histograms:
final DoubleHistogram tempHistogram = inactiveHistogram;
inactiveHistogram = activeHistogram;
activeHistogram = tempHistogram;
// Mark end time of previous interval and start time of new one:
long now = System.currentTimeMillis();
activeHistogram.setStartTimeStamp(now);
inactiveHistogram.setEndTimeStamp(now);
// Make sure we are not in the middle of recording a value on the previously active histogram:
// Flip phase to make sure no recordings that were in flight pre-flip are still active:
recordingPhaser.flipPhase(500000L /* yield in 0.5 msec units if needed */);
} finally {
recordingPhaser.readerUnlock();
}
}
private class InternalDoubleHistogram extends DoubleHistogram {
private final long containingInstanceId;
private InternalDoubleHistogram(long id, int numberOfSignificantValueDigits) {
super(numberOfSignificantValueDigits);
this.containingInstanceId = id;
}
private InternalDoubleHistogram(long id,
long highestToLowestValueRatio,
int numberOfSignificantValueDigits) {
super(highestToLowestValueRatio, numberOfSignificantValueDigits);
this.containingInstanceId = id;
}
private InternalDoubleHistogram(InternalDoubleHistogram source) {
super(source);
this.containingInstanceId = source.containingInstanceId;
}
}
private class PackedInternalDoubleHistogram extends PackedDoubleHistogram {
private final long containingInstanceId;
private PackedInternalDoubleHistogram(long id, int numberOfSignificantValueDigits) {
super(numberOfSignificantValueDigits);
this.containingInstanceId = id;
}
}
private void validateFitAsReplacementHistogram(DoubleHistogram replacementHistogram,
boolean enforceContainingInstance) {
boolean bad = true;
if (replacementHistogram == null) {
bad = false;
} else if ((replacementHistogram instanceof InternalDoubleHistogram)
&&
((!enforceContainingInstance) ||
(((InternalDoubleHistogram) replacementHistogram).containingInstanceId ==
((InternalDoubleHistogram)activeHistogram).containingInstanceId)
)) {
bad = false;
} else if ((replacementHistogram instanceof PackedInternalDoubleHistogram)
&&
((!enforceContainingInstance) ||
(((PackedInternalDoubleHistogram) replacementHistogram).containingInstanceId ==
((PackedInternalDoubleHistogram)activeHistogram).containingInstanceId)
)) {
bad = false;
}
if (bad) {
throw new IllegalArgumentException("replacement histogram must have been obtained via a previous " +
"getIntervalHistogram() call from this " + this.getClass().getName() +" instance");
}
}
} |
// the currently inactive histogram is reset each time we flip. So flipping twice resets both:
performIntervalSample();
performIntervalSample();
|
HdrHistogram_HdrHistogram | HdrHistogram/src/main/java/org/HdrHistogram/SingleWriterDoubleRecorder.java | SingleWriterDoubleRecorder | performIntervalSample | class SingleWriterDoubleRecorder implements DoubleValueRecorder, IntervalHistogramProvider<DoubleHistogram> {
private static AtomicLong instanceIdSequencer = new AtomicLong(1);
private final long instanceId = instanceIdSequencer.getAndIncrement();
private final WriterReaderPhaser recordingPhaser = new WriterReaderPhaser();
private volatile DoubleHistogram activeHistogram;
private DoubleHistogram inactiveHistogram;
/**
* Construct an auto-resizing {@link SingleWriterDoubleRecorder} using a precision stated as a
* number of significant decimal digits.
* <p>
* Depending on the valuer of the <b><code>packed</code></b> parameter {@link SingleWriterDoubleRecorder} can
* be configured to track value counts in a packed internal representation optimized for typical histogram
* recoded values are sparse in the value range and tend to be incremented in small unit counts. This packed
* representation tends to require significantly smaller amounts of storage when compared to unpacked
* representations, but can incur additional recording cost due to resizing and repacking operations that may
* occur as previously unrecorded values are encountered.
*
* @param numberOfSignificantValueDigits Specifies the precision to use. This is the number of significant
* decimal digits to which the histogram will maintain value resolution
* and separation. Must be a non-negative integer between 0 and 5.
* @param packed Specifies whether the recorder will uses a packed internal representation or not.
*/
public SingleWriterDoubleRecorder(final int numberOfSignificantValueDigits, final boolean packed) {
activeHistogram = packed ?
new PackedInternalDoubleHistogram(instanceId, numberOfSignificantValueDigits) :
new InternalDoubleHistogram(instanceId, numberOfSignificantValueDigits);
inactiveHistogram = null;
activeHistogram.setStartTimeStamp(System.currentTimeMillis());
}
/**
* Construct an auto-resizing {@link SingleWriterDoubleRecorder} using a precision stated as a
* number of significant decimal digits.
*
* @param numberOfSignificantValueDigits Specifies the precision to use. This is the number of significant
* decimal digits to which the histogram will maintain value resolution
* and separation. Must be a non-negative integer between 0 and 5.
*/
public SingleWriterDoubleRecorder(final int numberOfSignificantValueDigits) {
this(numberOfSignificantValueDigits, false);
}
/**
* Construct a {@link SingleWriterDoubleRecorder} dynamic range of values to cover and a number
* of significant decimal digits.
*
* @param highestToLowestValueRatio specifies the dynamic range to use (as a ratio)
* @param numberOfSignificantValueDigits Specifies the precision to use. This is the number of significant
* decimal digits to which the histogram will maintain value resolution
* and separation. Must be a non-negative integer between 0 and 5.
*/
public SingleWriterDoubleRecorder(final long highestToLowestValueRatio,
final int numberOfSignificantValueDigits) {
activeHistogram = new InternalDoubleHistogram(
instanceId, highestToLowestValueRatio, numberOfSignificantValueDigits);
inactiveHistogram = null;
activeHistogram.setStartTimeStamp(System.currentTimeMillis());
}
/**
* Record a value
* @param value the value to record
* @throws ArrayIndexOutOfBoundsException (may throw) if value is exceeds highestTrackableValue
*/
public void recordValue(final double value) {
long criticalValueAtEnter = recordingPhaser.writerCriticalSectionEnter();
try {
activeHistogram.recordValue(value);
} finally {
recordingPhaser.writerCriticalSectionExit(criticalValueAtEnter);
}
}
/**
* Record a value in the histogram (adding to the value's current count)
*
* @param value The value to be recorded
* @param count The number of occurrences of this value to record
* @throws ArrayIndexOutOfBoundsException (may throw) if value is exceeds highestTrackableValue
*/
public void recordValueWithCount(final double value, final long count) throws ArrayIndexOutOfBoundsException {
long criticalValueAtEnter = recordingPhaser.writerCriticalSectionEnter();
try {
activeHistogram.recordValueWithCount(value, count);
} finally {
recordingPhaser.writerCriticalSectionExit(criticalValueAtEnter);
}
}
/**
* Record a value
* <p>
* To compensate for the loss of sampled values when a recorded value is larger than the expected
* interval between value samples, Histogram will auto-generate an additional series of decreasingly-smaller
* (down to the expectedIntervalBetweenValueSamples) value records.
* <p>
* See related notes {@link org.HdrHistogram.DoubleHistogram#recordValueWithExpectedInterval(double, double)}
* for more explanations about coordinated omission and expected interval correction.
* *
* @param value The value to record
* @param expectedIntervalBetweenValueSamples If expectedIntervalBetweenValueSamples is larger than 0, add
* auto-generated value records as appropriate if value is larger
* than expectedIntervalBetweenValueSamples
* @throws ArrayIndexOutOfBoundsException (may throw) if value is exceeds highestTrackableValue
*/
public void recordValueWithExpectedInterval(final double value, final double expectedIntervalBetweenValueSamples)
throws ArrayIndexOutOfBoundsException {
long criticalValueAtEnter = recordingPhaser.writerCriticalSectionEnter();
try {
activeHistogram.recordValueWithExpectedInterval(value, expectedIntervalBetweenValueSamples);
} finally {
recordingPhaser.writerCriticalSectionExit(criticalValueAtEnter);
}
}
@Override
public synchronized DoubleHistogram getIntervalHistogram() {
return getIntervalHistogram(null);
}
@Override
public synchronized DoubleHistogram getIntervalHistogram(DoubleHistogram histogramToRecycle) {
return getIntervalHistogram(histogramToRecycle, true);
}
@Override
public synchronized DoubleHistogram getIntervalHistogram(DoubleHistogram histogramToRecycle,
boolean enforceContainingInstance) {
// Verify that replacement histogram can validly be used as an inactive histogram replacement:
validateFitAsReplacementHistogram(histogramToRecycle, enforceContainingInstance);
inactiveHistogram = histogramToRecycle;
performIntervalSample();
DoubleHistogram sampledHistogram = inactiveHistogram;
inactiveHistogram = null; // Once we expose the sample, we can't reuse it internally until it is recycled
return sampledHistogram;
}
@Override
public synchronized void getIntervalHistogramInto(DoubleHistogram targetHistogram) {
performIntervalSample();
inactiveHistogram.copyInto(targetHistogram);
}
/**
* Reset any value counts accumulated thus far.
*/
public synchronized void reset() {
// the currently inactive histogram is reset each time we flip. So flipping twice resets both:
performIntervalSample();
performIntervalSample();
}
private void performIntervalSample() {<FILL_FUNCTION_BODY>}
private class InternalDoubleHistogram extends DoubleHistogram {
private final long containingInstanceId;
private InternalDoubleHistogram(long id, int numberOfSignificantValueDigits) {
super(numberOfSignificantValueDigits);
this.containingInstanceId = id;
}
private InternalDoubleHistogram(long id,
long highestToLowestValueRatio,
int numberOfSignificantValueDigits) {
super(highestToLowestValueRatio, numberOfSignificantValueDigits);
this.containingInstanceId = id;
}
private InternalDoubleHistogram(InternalDoubleHistogram source) {
super(source);
this.containingInstanceId = source.containingInstanceId;
}
}
private class PackedInternalDoubleHistogram extends PackedDoubleHistogram {
private final long containingInstanceId;
private PackedInternalDoubleHistogram(long id, int numberOfSignificantValueDigits) {
super(numberOfSignificantValueDigits);
this.containingInstanceId = id;
}
}
private void validateFitAsReplacementHistogram(DoubleHistogram replacementHistogram,
boolean enforceContainingInstance) {
boolean bad = true;
if (replacementHistogram == null) {
bad = false;
} else if ((replacementHistogram instanceof InternalDoubleHistogram)
&&
((!enforceContainingInstance) ||
(((InternalDoubleHistogram) replacementHistogram).containingInstanceId ==
((InternalDoubleHistogram)activeHistogram).containingInstanceId)
)) {
bad = false;
} else if ((replacementHistogram instanceof PackedInternalDoubleHistogram)
&&
((!enforceContainingInstance) ||
(((PackedInternalDoubleHistogram) replacementHistogram).containingInstanceId ==
((PackedInternalDoubleHistogram)activeHistogram).containingInstanceId)
)) {
bad = false;
}
if (bad) {
throw new IllegalArgumentException("replacement histogram must have been obtained via a previous " +
"getIntervalHistogram() call from this " + this.getClass().getName() +" instance");
}
}
} |
try {
recordingPhaser.readerLock();
// Make sure we have an inactive version to flip in:
if (inactiveHistogram == null) {
if (activeHistogram instanceof InternalDoubleHistogram) {
inactiveHistogram = new InternalDoubleHistogram((InternalDoubleHistogram) activeHistogram);
} else if (activeHistogram instanceof PackedInternalDoubleHistogram) {
inactiveHistogram = new PackedInternalDoubleHistogram(
instanceId, activeHistogram.getNumberOfSignificantValueDigits());
} else {
throw new IllegalStateException("Unexpected internal histogram type for activeHistogram");
}
}
inactiveHistogram.reset();
// Swap active and inactive histograms:
final DoubleHistogram tempHistogram = inactiveHistogram;
inactiveHistogram = activeHistogram;
activeHistogram = tempHistogram;
// Mark end time of previous interval and start time of new one:
long now = System.currentTimeMillis();
activeHistogram.setStartTimeStamp(now);
inactiveHistogram.setEndTimeStamp(now);
// Make sure we are not in the middle of recording a value on the previously active histogram:
// Flip phase to make sure no recordings that were in flight pre-flip are still active:
recordingPhaser.flipPhase(500000L /* yield in 0.5 msec units if needed */);
} finally {
recordingPhaser.readerUnlock();
}
|
HdrHistogram_HdrHistogram | HdrHistogram/src/main/java/org/HdrHistogram/SingleWriterDoubleRecorder.java | PackedInternalDoubleHistogram | validateFitAsReplacementHistogram | class PackedInternalDoubleHistogram extends PackedDoubleHistogram {
private final long containingInstanceId;
private PackedInternalDoubleHistogram(long id, int numberOfSignificantValueDigits) {
super(numberOfSignificantValueDigits);
this.containingInstanceId = id;
}
}
private void validateFitAsReplacementHistogram(DoubleHistogram replacementHistogram,
boolean enforceContainingInstance) {<FILL_FUNCTION_BODY> |
boolean bad = true;
if (replacementHistogram == null) {
bad = false;
} else if ((replacementHistogram instanceof InternalDoubleHistogram)
&&
((!enforceContainingInstance) ||
(((InternalDoubleHistogram) replacementHistogram).containingInstanceId ==
((InternalDoubleHistogram)activeHistogram).containingInstanceId)
)) {
bad = false;
} else if ((replacementHistogram instanceof PackedInternalDoubleHistogram)
&&
((!enforceContainingInstance) ||
(((PackedInternalDoubleHistogram) replacementHistogram).containingInstanceId ==
((PackedInternalDoubleHistogram)activeHistogram).containingInstanceId)
)) {
bad = false;
}
if (bad) {
throw new IllegalArgumentException("replacement histogram must have been obtained via a previous " +
"getIntervalHistogram() call from this " + this.getClass().getName() +" instance");
}
|
HdrHistogram_HdrHistogram | HdrHistogram/src/main/java/org/HdrHistogram/packedarray/PackedArraySingleWriterRecorder.java | PackedArraySingleWriterRecorder | length | class PackedArraySingleWriterRecorder {
private static final AtomicLong instanceIdSequencer = new AtomicLong(1);
private final long instanceId = instanceIdSequencer.getAndIncrement();
private final WriterReaderPhaser recordingPhaser = new WriterReaderPhaser();
private volatile PackedLongArray activeArray;
/**
* Construct a {@link PackedArraySingleWriterRecorder} with a given (virtual) array length.
*
* @param virtualLength The (virtual) array length
*/
public PackedArraySingleWriterRecorder(final int virtualLength) {
activeArray = new InternalPackedLongArray(instanceId, virtualLength);
activeArray.setStartTimeStamp(System.currentTimeMillis());
}
/**
* Construct a {@link PackedArraySingleWriterRecorder} with a given (virtual) array length, starting with a given
* initial physical backing store length
*
* @param virtualLength The (virtual) array length
* @param initialPhysicalLength The initial physical backing store length
*/
public PackedArraySingleWriterRecorder(final int virtualLength, final int initialPhysicalLength) {
activeArray = new InternalPackedLongArray(instanceId, virtualLength, initialPhysicalLength);
activeArray.setStartTimeStamp(System.currentTimeMillis());
}
/**
* Returns the virtual length of the array represented by this recorder
* @return The virtual length of the array represented by this recorder
*/
public int length() {<FILL_FUNCTION_BODY>}
/**
* Change the (virtual) length of the array represented by the this recorder
* @param newVirtualLength the new (virtual) length to use
*/
public void setVirtualLength(int newVirtualLength) {
try {
recordingPhaser.readerLock();
// We don't care about concurrent modifications to the array, as setVirtualLength() in the
// ConcurrentPackedLongArray takes care of those. However, we must perform the change of virtual
// length under the recorder's readerLock protection to prevent mid-change observations:
activeArray.setVirtualLength(newVirtualLength);
} finally {
recordingPhaser.readerUnlock();
}
}
/**
* Increment a value at a given index in the array
* @param index the index of the value to be incremented
* @throws ArrayIndexOutOfBoundsException (may throw) if value is exceeds length()
*/
public void increment(final int index) throws ArrayIndexOutOfBoundsException {
long criticalValueAtEnter = recordingPhaser.writerCriticalSectionEnter();
try {
activeArray.increment(index);
} finally {
recordingPhaser.writerCriticalSectionExit(criticalValueAtEnter);
}
}
/**
* Add to a value at a given index in the array
* @param index The index of value to add to
* @param valueToAdd The amount to add to the value at the given index
* @throws ArrayIndexOutOfBoundsException (may throw) if value is exceeds length()
*/
public void add(final int index, final long valueToAdd) throws ArrayIndexOutOfBoundsException {
long criticalValueAtEnter = recordingPhaser.writerCriticalSectionEnter();
try {
activeArray.add(index, valueToAdd);
} finally {
recordingPhaser.writerCriticalSectionExit(criticalValueAtEnter);
}
}
/**
* Get an interval array, which will include a stable, consistent view of all values
* accumulated since the last interval array was taken.
* <p>
* Calling this method is equivalent to calling {@code getIntervalArray(null)}. It is generally recommended
* that the {@link PackedArraySingleWriterRecorder#getIntervalArray(PackedLongArray arrayToRecycle)
* getIntervalHistogram(arrayToRecycle)} orm be used for
* regular interval array sampling, as that form accepts a previously returned interval array that can be
* recycled internally to avoid allocation and content copying operations, and is therefore significantly
* more efficient for repeated use than {@link PackedArraySingleWriterRecorder#getIntervalArray()}.
* <p>
* Calling {@link PackedArraySingleWriterRecorder#getIntervalArray()} will reset the values at
* all indexes of the array tracked by the recorder, and start accumulating values for the next interval.
*
* @return an array containing the values accumulated since the last interval array was taken.
*/
public synchronized PackedLongArray getIntervalArray() {
return getIntervalArray(null);
}
/**
* Get an interval array, which will include a stable, consistent view of all values
* accumulated since the last interval array was taken.
* <p>
* {@link PackedArraySingleWriterRecorder#getIntervalArray(PackedLongArray arrayToRecycle)
* getIntervalArray(arrayToRecycle)}
* accepts a previously returned interval array that can be recycled internally to avoid allocation
* and content copying operations, and is therefore significantly more efficient for repeated use than
* {@link PackedArraySingleWriterRecorder#getIntervalArray()}. The provided {@code arrayToRecycle} must
* be either be null or an interval array returned by a previous call to
* {@link PackedArraySingleWriterRecorder#getIntervalArray(PackedLongArray arrayToRecycle)
* getIntervalArray(arrayToRecycle)} or
* {@link PackedArraySingleWriterRecorder#getIntervalArray()}.
* <p>
* NOTE: The caller is responsible for not recycling the same returned interval array more than once. If
* the same interval array instance is recycled more than once, behavior is undefined.
* <p>
* Calling {@link PackedArraySingleWriterRecorder#getIntervalArray(PackedLongArray arrayToRecycle)
* getIntervalArray(arrayToRecycle)} will reset the values at all indexes of the array
* tracked by the recorder, and start accumulating values for the next interval.
*
* @param arrayToRecycle a previously returned interval array (from this instance of
* {@link PackedArraySingleWriterRecorder}) that may be recycled to avoid allocation and
* copy operations.
* @return an array containing the values accumulated since the last interval array was taken.
*/
public synchronized PackedLongArray getIntervalArray(final PackedLongArray arrayToRecycle) {
return getIntervalArray(arrayToRecycle, true);
}
/**
* Get an interval array, which will include a stable, consistent view of all values
* accumulated since the last interval array was taken.
* <p>
* {@link PackedArraySingleWriterRecorder#getIntervalArray(PackedLongArray arrayToRecycle)
* getIntervalArray(arrayToRecycle)}
* accepts a previously returned interval array that can be recycled internally to avoid allocation
* and content copying operations, and is therefore significantly more efficient for repeated use than
* {@link PackedArraySingleWriterRecorder#getIntervalArray()}. The provided {@code arrayToRecycle} must
* be either be null or an interval array returned by a previous call to
* {@link PackedArraySingleWriterRecorder#getIntervalArray(PackedLongArray arrayToRecycle)
* getIntervalArray(arrayToRecycle)} or
* {@link PackedArraySingleWriterRecorder#getIntervalArray()}.
* <p>
* NOTE: The caller is responsible for not recycling the same returned interval array more than once. If
* the same interval array instance is recycled more than once, behavior is undefined.
* <p>
* Calling {@link PackedArraySingleWriterRecorder#getIntervalArray(PackedLongArray arrayToRecycle)
* getIntervalArray(arrayToRecycle, enforeContainingInstance)} will reset the values at all indexes
* of the array tracked by the recorder, and start accumulating values for the next interval.
*
* @param arrayToRecycle a previously returned interval array that may be recycled to avoid allocation and
* copy operations.
* @param enforceContainingInstance if true, will only allow recycling of arrays previously returned from this
* instance of {@link PackedArraySingleWriterRecorder}. If false, will allow recycling arrays
* previously returned by other instances of {@link PackedArraySingleWriterRecorder}.
* @return an array containing the values accumulated since the last interval array was taken.
*/
public synchronized PackedLongArray getIntervalArray(final PackedLongArray arrayToRecycle,
final boolean enforceContainingInstance) {
// Verify that replacement array can validly be used as an inactive array replacement:
validateFitAsReplacementArray(arrayToRecycle, enforceContainingInstance);
PackedLongArray sampledArray = performIntervalSample(arrayToRecycle);
return sampledArray;
}
/**
* Reset the array contents to all zeros.
*/
public synchronized void reset() {
// the currently active array is reset each time we flip:
performIntervalSample(null);
}
private PackedLongArray performIntervalSample(final PackedLongArray arrayToRecycle) {
PackedLongArray inactiveArray = arrayToRecycle;
try {
recordingPhaser.readerLock();
// Make sure we have an inactive version to flip in:
if (inactiveArray == null) {
if (activeArray instanceof InternalPackedLongArray) {
inactiveArray = new InternalPackedLongArray(instanceId, activeArray.length());
} else {
throw new IllegalStateException("Unexpected internal array type for activeArray");
}
} else {
inactiveArray.clear();
}
// Swap active and inactive arrays:
final PackedLongArray tempArray = inactiveArray;
inactiveArray = activeArray;
activeArray = tempArray;
// Mark end time of previous interval and start time of new one:
long now = System.currentTimeMillis();
activeArray.setStartTimeStamp(now);
inactiveArray.setEndTimeStamp(now);
// Make sure we are not in the middle of recording a value on the previously active array:
// Flip phase to make sure no recordings that were in flight pre-flip are still active:
recordingPhaser.flipPhase(500000L /* yield in 0.5 msec units if needed */);
} finally {
recordingPhaser.readerUnlock();
}
return inactiveArray;
}
private static class InternalPackedLongArray extends PackedLongArray {
private final long containingInstanceId;
private InternalPackedLongArray(final long id, int virtualLength, final int initialPhysicalLength) {
super(virtualLength, initialPhysicalLength);
this.containingInstanceId = id;
}
private InternalPackedLongArray(final long id, final int virtualLength) {
super(virtualLength);
this.containingInstanceId = id;
}
}
private void validateFitAsReplacementArray(final PackedLongArray replacementArray,
final boolean enforceContainingInstance) {
boolean bad = true;
if (replacementArray == null) {
bad = false;
} else if (replacementArray instanceof InternalPackedLongArray) {
if ((activeArray instanceof InternalPackedLongArray)
&&
((!enforceContainingInstance) ||
(((InternalPackedLongArray)replacementArray).containingInstanceId ==
((InternalPackedLongArray) activeArray).containingInstanceId)
)) {
bad = false;
}
}
if (bad) {
throw new IllegalArgumentException("replacement array must have been obtained via a previous" +
" getIntervalArray() call from this " + this.getClass().getName() +
(enforceContainingInstance ? " instance" : " class"));
}
}
} |
return activeArray.length();
|
HdrHistogram_HdrHistogram | HdrHistogram/src/main/java/org/HdrHistogram/packedarray/PackedArraySingleWriterRecorder.java | PackedArraySingleWriterRecorder | setVirtualLength | class PackedArraySingleWriterRecorder {
private static final AtomicLong instanceIdSequencer = new AtomicLong(1);
private final long instanceId = instanceIdSequencer.getAndIncrement();
private final WriterReaderPhaser recordingPhaser = new WriterReaderPhaser();
private volatile PackedLongArray activeArray;
/**
* Construct a {@link PackedArraySingleWriterRecorder} with a given (virtual) array length.
*
* @param virtualLength The (virtual) array length
*/
public PackedArraySingleWriterRecorder(final int virtualLength) {
activeArray = new InternalPackedLongArray(instanceId, virtualLength);
activeArray.setStartTimeStamp(System.currentTimeMillis());
}
/**
* Construct a {@link PackedArraySingleWriterRecorder} with a given (virtual) array length, starting with a given
* initial physical backing store length
*
* @param virtualLength The (virtual) array length
* @param initialPhysicalLength The initial physical backing store length
*/
public PackedArraySingleWriterRecorder(final int virtualLength, final int initialPhysicalLength) {
activeArray = new InternalPackedLongArray(instanceId, virtualLength, initialPhysicalLength);
activeArray.setStartTimeStamp(System.currentTimeMillis());
}
/**
* Returns the virtual length of the array represented by this recorder
* @return The virtual length of the array represented by this recorder
*/
public int length() {
return activeArray.length();
}
/**
* Change the (virtual) length of the array represented by the this recorder
* @param newVirtualLength the new (virtual) length to use
*/
public void setVirtualLength(int newVirtualLength) {<FILL_FUNCTION_BODY>}
/**
* Increment a value at a given index in the array
* @param index the index of the value to be incremented
* @throws ArrayIndexOutOfBoundsException (may throw) if value is exceeds length()
*/
public void increment(final int index) throws ArrayIndexOutOfBoundsException {
long criticalValueAtEnter = recordingPhaser.writerCriticalSectionEnter();
try {
activeArray.increment(index);
} finally {
recordingPhaser.writerCriticalSectionExit(criticalValueAtEnter);
}
}
/**
* Add to a value at a given index in the array
* @param index The index of value to add to
* @param valueToAdd The amount to add to the value at the given index
* @throws ArrayIndexOutOfBoundsException (may throw) if value is exceeds length()
*/
public void add(final int index, final long valueToAdd) throws ArrayIndexOutOfBoundsException {
long criticalValueAtEnter = recordingPhaser.writerCriticalSectionEnter();
try {
activeArray.add(index, valueToAdd);
} finally {
recordingPhaser.writerCriticalSectionExit(criticalValueAtEnter);
}
}
/**
* Get an interval array, which will include a stable, consistent view of all values
* accumulated since the last interval array was taken.
* <p>
* Calling this method is equivalent to calling {@code getIntervalArray(null)}. It is generally recommended
* that the {@link PackedArraySingleWriterRecorder#getIntervalArray(PackedLongArray arrayToRecycle)
* getIntervalHistogram(arrayToRecycle)} orm be used for
* regular interval array sampling, as that form accepts a previously returned interval array that can be
* recycled internally to avoid allocation and content copying operations, and is therefore significantly
* more efficient for repeated use than {@link PackedArraySingleWriterRecorder#getIntervalArray()}.
* <p>
* Calling {@link PackedArraySingleWriterRecorder#getIntervalArray()} will reset the values at
* all indexes of the array tracked by the recorder, and start accumulating values for the next interval.
*
* @return an array containing the values accumulated since the last interval array was taken.
*/
public synchronized PackedLongArray getIntervalArray() {
return getIntervalArray(null);
}
/**
* Get an interval array, which will include a stable, consistent view of all values
* accumulated since the last interval array was taken.
* <p>
* {@link PackedArraySingleWriterRecorder#getIntervalArray(PackedLongArray arrayToRecycle)
* getIntervalArray(arrayToRecycle)}
* accepts a previously returned interval array that can be recycled internally to avoid allocation
* and content copying operations, and is therefore significantly more efficient for repeated use than
* {@link PackedArraySingleWriterRecorder#getIntervalArray()}. The provided {@code arrayToRecycle} must
* be either be null or an interval array returned by a previous call to
* {@link PackedArraySingleWriterRecorder#getIntervalArray(PackedLongArray arrayToRecycle)
* getIntervalArray(arrayToRecycle)} or
* {@link PackedArraySingleWriterRecorder#getIntervalArray()}.
* <p>
* NOTE: The caller is responsible for not recycling the same returned interval array more than once. If
* the same interval array instance is recycled more than once, behavior is undefined.
* <p>
* Calling {@link PackedArraySingleWriterRecorder#getIntervalArray(PackedLongArray arrayToRecycle)
* getIntervalArray(arrayToRecycle)} will reset the values at all indexes of the array
* tracked by the recorder, and start accumulating values for the next interval.
*
* @param arrayToRecycle a previously returned interval array (from this instance of
* {@link PackedArraySingleWriterRecorder}) that may be recycled to avoid allocation and
* copy operations.
* @return an array containing the values accumulated since the last interval array was taken.
*/
public synchronized PackedLongArray getIntervalArray(final PackedLongArray arrayToRecycle) {
return getIntervalArray(arrayToRecycle, true);
}
/**
* Get an interval array, which will include a stable, consistent view of all values
* accumulated since the last interval array was taken.
* <p>
* {@link PackedArraySingleWriterRecorder#getIntervalArray(PackedLongArray arrayToRecycle)
* getIntervalArray(arrayToRecycle)}
* accepts a previously returned interval array that can be recycled internally to avoid allocation
* and content copying operations, and is therefore significantly more efficient for repeated use than
* {@link PackedArraySingleWriterRecorder#getIntervalArray()}. The provided {@code arrayToRecycle} must
* be either be null or an interval array returned by a previous call to
* {@link PackedArraySingleWriterRecorder#getIntervalArray(PackedLongArray arrayToRecycle)
* getIntervalArray(arrayToRecycle)} or
* {@link PackedArraySingleWriterRecorder#getIntervalArray()}.
* <p>
* NOTE: The caller is responsible for not recycling the same returned interval array more than once. If
* the same interval array instance is recycled more than once, behavior is undefined.
* <p>
* Calling {@link PackedArraySingleWriterRecorder#getIntervalArray(PackedLongArray arrayToRecycle)
* getIntervalArray(arrayToRecycle, enforeContainingInstance)} will reset the values at all indexes
* of the array tracked by the recorder, and start accumulating values for the next interval.
*
* @param arrayToRecycle a previously returned interval array that may be recycled to avoid allocation and
* copy operations.
* @param enforceContainingInstance if true, will only allow recycling of arrays previously returned from this
* instance of {@link PackedArraySingleWriterRecorder}. If false, will allow recycling arrays
* previously returned by other instances of {@link PackedArraySingleWriterRecorder}.
* @return an array containing the values accumulated since the last interval array was taken.
*/
public synchronized PackedLongArray getIntervalArray(final PackedLongArray arrayToRecycle,
final boolean enforceContainingInstance) {
// Verify that replacement array can validly be used as an inactive array replacement:
validateFitAsReplacementArray(arrayToRecycle, enforceContainingInstance);
PackedLongArray sampledArray = performIntervalSample(arrayToRecycle);
return sampledArray;
}
/**
* Reset the array contents to all zeros.
*/
public synchronized void reset() {
// the currently active array is reset each time we flip:
performIntervalSample(null);
}
private PackedLongArray performIntervalSample(final PackedLongArray arrayToRecycle) {
PackedLongArray inactiveArray = arrayToRecycle;
try {
recordingPhaser.readerLock();
// Make sure we have an inactive version to flip in:
if (inactiveArray == null) {
if (activeArray instanceof InternalPackedLongArray) {
inactiveArray = new InternalPackedLongArray(instanceId, activeArray.length());
} else {
throw new IllegalStateException("Unexpected internal array type for activeArray");
}
} else {
inactiveArray.clear();
}
// Swap active and inactive arrays:
final PackedLongArray tempArray = inactiveArray;
inactiveArray = activeArray;
activeArray = tempArray;
// Mark end time of previous interval and start time of new one:
long now = System.currentTimeMillis();
activeArray.setStartTimeStamp(now);
inactiveArray.setEndTimeStamp(now);
// Make sure we are not in the middle of recording a value on the previously active array:
// Flip phase to make sure no recordings that were in flight pre-flip are still active:
recordingPhaser.flipPhase(500000L /* yield in 0.5 msec units if needed */);
} finally {
recordingPhaser.readerUnlock();
}
return inactiveArray;
}
private static class InternalPackedLongArray extends PackedLongArray {
private final long containingInstanceId;
private InternalPackedLongArray(final long id, int virtualLength, final int initialPhysicalLength) {
super(virtualLength, initialPhysicalLength);
this.containingInstanceId = id;
}
private InternalPackedLongArray(final long id, final int virtualLength) {
super(virtualLength);
this.containingInstanceId = id;
}
}
private void validateFitAsReplacementArray(final PackedLongArray replacementArray,
final boolean enforceContainingInstance) {
boolean bad = true;
if (replacementArray == null) {
bad = false;
} else if (replacementArray instanceof InternalPackedLongArray) {
if ((activeArray instanceof InternalPackedLongArray)
&&
((!enforceContainingInstance) ||
(((InternalPackedLongArray)replacementArray).containingInstanceId ==
((InternalPackedLongArray) activeArray).containingInstanceId)
)) {
bad = false;
}
}
if (bad) {
throw new IllegalArgumentException("replacement array must have been obtained via a previous" +
" getIntervalArray() call from this " + this.getClass().getName() +
(enforceContainingInstance ? " instance" : " class"));
}
}
} |
try {
recordingPhaser.readerLock();
// We don't care about concurrent modifications to the array, as setVirtualLength() in the
// ConcurrentPackedLongArray takes care of those. However, we must perform the change of virtual
// length under the recorder's readerLock protection to prevent mid-change observations:
activeArray.setVirtualLength(newVirtualLength);
} finally {
recordingPhaser.readerUnlock();
}
|
HdrHistogram_HdrHistogram | HdrHistogram/src/main/java/org/HdrHistogram/packedarray/PackedArraySingleWriterRecorder.java | PackedArraySingleWriterRecorder | increment | class PackedArraySingleWriterRecorder {
private static final AtomicLong instanceIdSequencer = new AtomicLong(1);
private final long instanceId = instanceIdSequencer.getAndIncrement();
private final WriterReaderPhaser recordingPhaser = new WriterReaderPhaser();
private volatile PackedLongArray activeArray;
/**
* Construct a {@link PackedArraySingleWriterRecorder} with a given (virtual) array length.
*
* @param virtualLength The (virtual) array length
*/
public PackedArraySingleWriterRecorder(final int virtualLength) {
activeArray = new InternalPackedLongArray(instanceId, virtualLength);
activeArray.setStartTimeStamp(System.currentTimeMillis());
}
/**
* Construct a {@link PackedArraySingleWriterRecorder} with a given (virtual) array length, starting with a given
* initial physical backing store length
*
* @param virtualLength The (virtual) array length
* @param initialPhysicalLength The initial physical backing store length
*/
public PackedArraySingleWriterRecorder(final int virtualLength, final int initialPhysicalLength) {
activeArray = new InternalPackedLongArray(instanceId, virtualLength, initialPhysicalLength);
activeArray.setStartTimeStamp(System.currentTimeMillis());
}
/**
* Returns the virtual length of the array represented by this recorder
* @return The virtual length of the array represented by this recorder
*/
public int length() {
return activeArray.length();
}
/**
* Change the (virtual) length of the array represented by the this recorder
* @param newVirtualLength the new (virtual) length to use
*/
public void setVirtualLength(int newVirtualLength) {
try {
recordingPhaser.readerLock();
// We don't care about concurrent modifications to the array, as setVirtualLength() in the
// ConcurrentPackedLongArray takes care of those. However, we must perform the change of virtual
// length under the recorder's readerLock protection to prevent mid-change observations:
activeArray.setVirtualLength(newVirtualLength);
} finally {
recordingPhaser.readerUnlock();
}
}
/**
* Increment a value at a given index in the array
* @param index the index of the value to be incremented
* @throws ArrayIndexOutOfBoundsException (may throw) if value is exceeds length()
*/
public void increment(final int index) throws ArrayIndexOutOfBoundsException {<FILL_FUNCTION_BODY>}
/**
* Add to a value at a given index in the array
* @param index The index of value to add to
* @param valueToAdd The amount to add to the value at the given index
* @throws ArrayIndexOutOfBoundsException (may throw) if value is exceeds length()
*/
public void add(final int index, final long valueToAdd) throws ArrayIndexOutOfBoundsException {
long criticalValueAtEnter = recordingPhaser.writerCriticalSectionEnter();
try {
activeArray.add(index, valueToAdd);
} finally {
recordingPhaser.writerCriticalSectionExit(criticalValueAtEnter);
}
}
/**
* Get an interval array, which will include a stable, consistent view of all values
* accumulated since the last interval array was taken.
* <p>
* Calling this method is equivalent to calling {@code getIntervalArray(null)}. It is generally recommended
* that the {@link PackedArraySingleWriterRecorder#getIntervalArray(PackedLongArray arrayToRecycle)
* getIntervalHistogram(arrayToRecycle)} orm be used for
* regular interval array sampling, as that form accepts a previously returned interval array that can be
* recycled internally to avoid allocation and content copying operations, and is therefore significantly
* more efficient for repeated use than {@link PackedArraySingleWriterRecorder#getIntervalArray()}.
* <p>
* Calling {@link PackedArraySingleWriterRecorder#getIntervalArray()} will reset the values at
* all indexes of the array tracked by the recorder, and start accumulating values for the next interval.
*
* @return an array containing the values accumulated since the last interval array was taken.
*/
public synchronized PackedLongArray getIntervalArray() {
return getIntervalArray(null);
}
/**
* Get an interval array, which will include a stable, consistent view of all values
* accumulated since the last interval array was taken.
* <p>
* {@link PackedArraySingleWriterRecorder#getIntervalArray(PackedLongArray arrayToRecycle)
* getIntervalArray(arrayToRecycle)}
* accepts a previously returned interval array that can be recycled internally to avoid allocation
* and content copying operations, and is therefore significantly more efficient for repeated use than
* {@link PackedArraySingleWriterRecorder#getIntervalArray()}. The provided {@code arrayToRecycle} must
* be either be null or an interval array returned by a previous call to
* {@link PackedArraySingleWriterRecorder#getIntervalArray(PackedLongArray arrayToRecycle)
* getIntervalArray(arrayToRecycle)} or
* {@link PackedArraySingleWriterRecorder#getIntervalArray()}.
* <p>
* NOTE: The caller is responsible for not recycling the same returned interval array more than once. If
* the same interval array instance is recycled more than once, behavior is undefined.
* <p>
* Calling {@link PackedArraySingleWriterRecorder#getIntervalArray(PackedLongArray arrayToRecycle)
* getIntervalArray(arrayToRecycle)} will reset the values at all indexes of the array
* tracked by the recorder, and start accumulating values for the next interval.
*
* @param arrayToRecycle a previously returned interval array (from this instance of
* {@link PackedArraySingleWriterRecorder}) that may be recycled to avoid allocation and
* copy operations.
* @return an array containing the values accumulated since the last interval array was taken.
*/
public synchronized PackedLongArray getIntervalArray(final PackedLongArray arrayToRecycle) {
return getIntervalArray(arrayToRecycle, true);
}
/**
* Get an interval array, which will include a stable, consistent view of all values
* accumulated since the last interval array was taken.
* <p>
* {@link PackedArraySingleWriterRecorder#getIntervalArray(PackedLongArray arrayToRecycle)
* getIntervalArray(arrayToRecycle)}
* accepts a previously returned interval array that can be recycled internally to avoid allocation
* and content copying operations, and is therefore significantly more efficient for repeated use than
* {@link PackedArraySingleWriterRecorder#getIntervalArray()}. The provided {@code arrayToRecycle} must
* be either be null or an interval array returned by a previous call to
* {@link PackedArraySingleWriterRecorder#getIntervalArray(PackedLongArray arrayToRecycle)
* getIntervalArray(arrayToRecycle)} or
* {@link PackedArraySingleWriterRecorder#getIntervalArray()}.
* <p>
* NOTE: The caller is responsible for not recycling the same returned interval array more than once. If
* the same interval array instance is recycled more than once, behavior is undefined.
* <p>
* Calling {@link PackedArraySingleWriterRecorder#getIntervalArray(PackedLongArray arrayToRecycle)
* getIntervalArray(arrayToRecycle, enforeContainingInstance)} will reset the values at all indexes
* of the array tracked by the recorder, and start accumulating values for the next interval.
*
* @param arrayToRecycle a previously returned interval array that may be recycled to avoid allocation and
* copy operations.
* @param enforceContainingInstance if true, will only allow recycling of arrays previously returned from this
* instance of {@link PackedArraySingleWriterRecorder}. If false, will allow recycling arrays
* previously returned by other instances of {@link PackedArraySingleWriterRecorder}.
* @return an array containing the values accumulated since the last interval array was taken.
*/
public synchronized PackedLongArray getIntervalArray(final PackedLongArray arrayToRecycle,
final boolean enforceContainingInstance) {
// Verify that replacement array can validly be used as an inactive array replacement:
validateFitAsReplacementArray(arrayToRecycle, enforceContainingInstance);
PackedLongArray sampledArray = performIntervalSample(arrayToRecycle);
return sampledArray;
}
/**
* Reset the array contents to all zeros.
*/
public synchronized void reset() {
// the currently active array is reset each time we flip:
performIntervalSample(null);
}
private PackedLongArray performIntervalSample(final PackedLongArray arrayToRecycle) {
PackedLongArray inactiveArray = arrayToRecycle;
try {
recordingPhaser.readerLock();
// Make sure we have an inactive version to flip in:
if (inactiveArray == null) {
if (activeArray instanceof InternalPackedLongArray) {
inactiveArray = new InternalPackedLongArray(instanceId, activeArray.length());
} else {
throw new IllegalStateException("Unexpected internal array type for activeArray");
}
} else {
inactiveArray.clear();
}
// Swap active and inactive arrays:
final PackedLongArray tempArray = inactiveArray;
inactiveArray = activeArray;
activeArray = tempArray;
// Mark end time of previous interval and start time of new one:
long now = System.currentTimeMillis();
activeArray.setStartTimeStamp(now);
inactiveArray.setEndTimeStamp(now);
// Make sure we are not in the middle of recording a value on the previously active array:
// Flip phase to make sure no recordings that were in flight pre-flip are still active:
recordingPhaser.flipPhase(500000L /* yield in 0.5 msec units if needed */);
} finally {
recordingPhaser.readerUnlock();
}
return inactiveArray;
}
private static class InternalPackedLongArray extends PackedLongArray {
private final long containingInstanceId;
private InternalPackedLongArray(final long id, int virtualLength, final int initialPhysicalLength) {
super(virtualLength, initialPhysicalLength);
this.containingInstanceId = id;
}
private InternalPackedLongArray(final long id, final int virtualLength) {
super(virtualLength);
this.containingInstanceId = id;
}
}
private void validateFitAsReplacementArray(final PackedLongArray replacementArray,
final boolean enforceContainingInstance) {
boolean bad = true;
if (replacementArray == null) {
bad = false;
} else if (replacementArray instanceof InternalPackedLongArray) {
if ((activeArray instanceof InternalPackedLongArray)
&&
((!enforceContainingInstance) ||
(((InternalPackedLongArray)replacementArray).containingInstanceId ==
((InternalPackedLongArray) activeArray).containingInstanceId)
)) {
bad = false;
}
}
if (bad) {
throw new IllegalArgumentException("replacement array must have been obtained via a previous" +
" getIntervalArray() call from this " + this.getClass().getName() +
(enforceContainingInstance ? " instance" : " class"));
}
}
} |
long criticalValueAtEnter = recordingPhaser.writerCriticalSectionEnter();
try {
activeArray.increment(index);
} finally {
recordingPhaser.writerCriticalSectionExit(criticalValueAtEnter);
}
|
HdrHistogram_HdrHistogram | HdrHistogram/src/main/java/org/HdrHistogram/packedarray/PackedArraySingleWriterRecorder.java | PackedArraySingleWriterRecorder | add | class PackedArraySingleWriterRecorder {
private static final AtomicLong instanceIdSequencer = new AtomicLong(1);
private final long instanceId = instanceIdSequencer.getAndIncrement();
private final WriterReaderPhaser recordingPhaser = new WriterReaderPhaser();
private volatile PackedLongArray activeArray;
/**
* Construct a {@link PackedArraySingleWriterRecorder} with a given (virtual) array length.
*
* @param virtualLength The (virtual) array length
*/
public PackedArraySingleWriterRecorder(final int virtualLength) {
activeArray = new InternalPackedLongArray(instanceId, virtualLength);
activeArray.setStartTimeStamp(System.currentTimeMillis());
}
/**
* Construct a {@link PackedArraySingleWriterRecorder} with a given (virtual) array length, starting with a given
* initial physical backing store length
*
* @param virtualLength The (virtual) array length
* @param initialPhysicalLength The initial physical backing store length
*/
public PackedArraySingleWriterRecorder(final int virtualLength, final int initialPhysicalLength) {
activeArray = new InternalPackedLongArray(instanceId, virtualLength, initialPhysicalLength);
activeArray.setStartTimeStamp(System.currentTimeMillis());
}
/**
* Returns the virtual length of the array represented by this recorder
* @return The virtual length of the array represented by this recorder
*/
public int length() {
return activeArray.length();
}
/**
* Change the (virtual) length of the array represented by the this recorder
* @param newVirtualLength the new (virtual) length to use
*/
public void setVirtualLength(int newVirtualLength) {
try {
recordingPhaser.readerLock();
// We don't care about concurrent modifications to the array, as setVirtualLength() in the
// ConcurrentPackedLongArray takes care of those. However, we must perform the change of virtual
// length under the recorder's readerLock protection to prevent mid-change observations:
activeArray.setVirtualLength(newVirtualLength);
} finally {
recordingPhaser.readerUnlock();
}
}
/**
* Increment a value at a given index in the array
* @param index the index of the value to be incremented
* @throws ArrayIndexOutOfBoundsException (may throw) if value is exceeds length()
*/
public void increment(final int index) throws ArrayIndexOutOfBoundsException {
long criticalValueAtEnter = recordingPhaser.writerCriticalSectionEnter();
try {
activeArray.increment(index);
} finally {
recordingPhaser.writerCriticalSectionExit(criticalValueAtEnter);
}
}
/**
* Add to a value at a given index in the array
* @param index The index of value to add to
* @param valueToAdd The amount to add to the value at the given index
* @throws ArrayIndexOutOfBoundsException (may throw) if value is exceeds length()
*/
public void add(final int index, final long valueToAdd) throws ArrayIndexOutOfBoundsException {<FILL_FUNCTION_BODY>}
/**
* Get an interval array, which will include a stable, consistent view of all values
* accumulated since the last interval array was taken.
* <p>
* Calling this method is equivalent to calling {@code getIntervalArray(null)}. It is generally recommended
* that the {@link PackedArraySingleWriterRecorder#getIntervalArray(PackedLongArray arrayToRecycle)
* getIntervalHistogram(arrayToRecycle)} orm be used for
* regular interval array sampling, as that form accepts a previously returned interval array that can be
* recycled internally to avoid allocation and content copying operations, and is therefore significantly
* more efficient for repeated use than {@link PackedArraySingleWriterRecorder#getIntervalArray()}.
* <p>
* Calling {@link PackedArraySingleWriterRecorder#getIntervalArray()} will reset the values at
* all indexes of the array tracked by the recorder, and start accumulating values for the next interval.
*
* @return an array containing the values accumulated since the last interval array was taken.
*/
public synchronized PackedLongArray getIntervalArray() {
return getIntervalArray(null);
}
/**
* Get an interval array, which will include a stable, consistent view of all values
* accumulated since the last interval array was taken.
* <p>
* {@link PackedArraySingleWriterRecorder#getIntervalArray(PackedLongArray arrayToRecycle)
* getIntervalArray(arrayToRecycle)}
* accepts a previously returned interval array that can be recycled internally to avoid allocation
* and content copying operations, and is therefore significantly more efficient for repeated use than
* {@link PackedArraySingleWriterRecorder#getIntervalArray()}. The provided {@code arrayToRecycle} must
* be either be null or an interval array returned by a previous call to
* {@link PackedArraySingleWriterRecorder#getIntervalArray(PackedLongArray arrayToRecycle)
* getIntervalArray(arrayToRecycle)} or
* {@link PackedArraySingleWriterRecorder#getIntervalArray()}.
* <p>
* NOTE: The caller is responsible for not recycling the same returned interval array more than once. If
* the same interval array instance is recycled more than once, behavior is undefined.
* <p>
* Calling {@link PackedArraySingleWriterRecorder#getIntervalArray(PackedLongArray arrayToRecycle)
* getIntervalArray(arrayToRecycle)} will reset the values at all indexes of the array
* tracked by the recorder, and start accumulating values for the next interval.
*
* @param arrayToRecycle a previously returned interval array (from this instance of
* {@link PackedArraySingleWriterRecorder}) that may be recycled to avoid allocation and
* copy operations.
* @return an array containing the values accumulated since the last interval array was taken.
*/
public synchronized PackedLongArray getIntervalArray(final PackedLongArray arrayToRecycle) {
return getIntervalArray(arrayToRecycle, true);
}
/**
* Get an interval array, which will include a stable, consistent view of all values
* accumulated since the last interval array was taken.
* <p>
* {@link PackedArraySingleWriterRecorder#getIntervalArray(PackedLongArray arrayToRecycle)
* getIntervalArray(arrayToRecycle)}
* accepts a previously returned interval array that can be recycled internally to avoid allocation
* and content copying operations, and is therefore significantly more efficient for repeated use than
* {@link PackedArraySingleWriterRecorder#getIntervalArray()}. The provided {@code arrayToRecycle} must
* be either be null or an interval array returned by a previous call to
* {@link PackedArraySingleWriterRecorder#getIntervalArray(PackedLongArray arrayToRecycle)
* getIntervalArray(arrayToRecycle)} or
* {@link PackedArraySingleWriterRecorder#getIntervalArray()}.
* <p>
* NOTE: The caller is responsible for not recycling the same returned interval array more than once. If
* the same interval array instance is recycled more than once, behavior is undefined.
* <p>
* Calling {@link PackedArraySingleWriterRecorder#getIntervalArray(PackedLongArray arrayToRecycle)
* getIntervalArray(arrayToRecycle, enforeContainingInstance)} will reset the values at all indexes
* of the array tracked by the recorder, and start accumulating values for the next interval.
*
* @param arrayToRecycle a previously returned interval array that may be recycled to avoid allocation and
* copy operations.
* @param enforceContainingInstance if true, will only allow recycling of arrays previously returned from this
* instance of {@link PackedArraySingleWriterRecorder}. If false, will allow recycling arrays
* previously returned by other instances of {@link PackedArraySingleWriterRecorder}.
* @return an array containing the values accumulated since the last interval array was taken.
*/
public synchronized PackedLongArray getIntervalArray(final PackedLongArray arrayToRecycle,
final boolean enforceContainingInstance) {
// Verify that replacement array can validly be used as an inactive array replacement:
validateFitAsReplacementArray(arrayToRecycle, enforceContainingInstance);
PackedLongArray sampledArray = performIntervalSample(arrayToRecycle);
return sampledArray;
}
/**
* Reset the array contents to all zeros.
*/
public synchronized void reset() {
// the currently active array is reset each time we flip:
performIntervalSample(null);
}
private PackedLongArray performIntervalSample(final PackedLongArray arrayToRecycle) {
PackedLongArray inactiveArray = arrayToRecycle;
try {
recordingPhaser.readerLock();
// Make sure we have an inactive version to flip in:
if (inactiveArray == null) {
if (activeArray instanceof InternalPackedLongArray) {
inactiveArray = new InternalPackedLongArray(instanceId, activeArray.length());
} else {
throw new IllegalStateException("Unexpected internal array type for activeArray");
}
} else {
inactiveArray.clear();
}
// Swap active and inactive arrays:
final PackedLongArray tempArray = inactiveArray;
inactiveArray = activeArray;
activeArray = tempArray;
// Mark end time of previous interval and start time of new one:
long now = System.currentTimeMillis();
activeArray.setStartTimeStamp(now);
inactiveArray.setEndTimeStamp(now);
// Make sure we are not in the middle of recording a value on the previously active array:
// Flip phase to make sure no recordings that were in flight pre-flip are still active:
recordingPhaser.flipPhase(500000L /* yield in 0.5 msec units if needed */);
} finally {
recordingPhaser.readerUnlock();
}
return inactiveArray;
}
private static class InternalPackedLongArray extends PackedLongArray {
private final long containingInstanceId;
private InternalPackedLongArray(final long id, int virtualLength, final int initialPhysicalLength) {
super(virtualLength, initialPhysicalLength);
this.containingInstanceId = id;
}
private InternalPackedLongArray(final long id, final int virtualLength) {
super(virtualLength);
this.containingInstanceId = id;
}
}
private void validateFitAsReplacementArray(final PackedLongArray replacementArray,
final boolean enforceContainingInstance) {
boolean bad = true;
if (replacementArray == null) {
bad = false;
} else if (replacementArray instanceof InternalPackedLongArray) {
if ((activeArray instanceof InternalPackedLongArray)
&&
((!enforceContainingInstance) ||
(((InternalPackedLongArray)replacementArray).containingInstanceId ==
((InternalPackedLongArray) activeArray).containingInstanceId)
)) {
bad = false;
}
}
if (bad) {
throw new IllegalArgumentException("replacement array must have been obtained via a previous" +
" getIntervalArray() call from this " + this.getClass().getName() +
(enforceContainingInstance ? " instance" : " class"));
}
}
} |
long criticalValueAtEnter = recordingPhaser.writerCriticalSectionEnter();
try {
activeArray.add(index, valueToAdd);
} finally {
recordingPhaser.writerCriticalSectionExit(criticalValueAtEnter);
}
|
HdrHistogram_HdrHistogram | HdrHistogram/src/main/java/org/HdrHistogram/packedarray/PackedArraySingleWriterRecorder.java | PackedArraySingleWriterRecorder | getIntervalArray | class PackedArraySingleWriterRecorder {
private static final AtomicLong instanceIdSequencer = new AtomicLong(1);
private final long instanceId = instanceIdSequencer.getAndIncrement();
private final WriterReaderPhaser recordingPhaser = new WriterReaderPhaser();
private volatile PackedLongArray activeArray;
/**
* Construct a {@link PackedArraySingleWriterRecorder} with a given (virtual) array length.
*
* @param virtualLength The (virtual) array length
*/
public PackedArraySingleWriterRecorder(final int virtualLength) {
activeArray = new InternalPackedLongArray(instanceId, virtualLength);
activeArray.setStartTimeStamp(System.currentTimeMillis());
}
/**
* Construct a {@link PackedArraySingleWriterRecorder} with a given (virtual) array length, starting with a given
* initial physical backing store length
*
* @param virtualLength The (virtual) array length
* @param initialPhysicalLength The initial physical backing store length
*/
public PackedArraySingleWriterRecorder(final int virtualLength, final int initialPhysicalLength) {
activeArray = new InternalPackedLongArray(instanceId, virtualLength, initialPhysicalLength);
activeArray.setStartTimeStamp(System.currentTimeMillis());
}
/**
* Returns the virtual length of the array represented by this recorder
* @return The virtual length of the array represented by this recorder
*/
public int length() {
return activeArray.length();
}
/**
* Change the (virtual) length of the array represented by the this recorder
* @param newVirtualLength the new (virtual) length to use
*/
public void setVirtualLength(int newVirtualLength) {
try {
recordingPhaser.readerLock();
// We don't care about concurrent modifications to the array, as setVirtualLength() in the
// ConcurrentPackedLongArray takes care of those. However, we must perform the change of virtual
// length under the recorder's readerLock protection to prevent mid-change observations:
activeArray.setVirtualLength(newVirtualLength);
} finally {
recordingPhaser.readerUnlock();
}
}
/**
* Increment a value at a given index in the array
* @param index the index of the value to be incremented
* @throws ArrayIndexOutOfBoundsException (may throw) if value is exceeds length()
*/
public void increment(final int index) throws ArrayIndexOutOfBoundsException {
long criticalValueAtEnter = recordingPhaser.writerCriticalSectionEnter();
try {
activeArray.increment(index);
} finally {
recordingPhaser.writerCriticalSectionExit(criticalValueAtEnter);
}
}
/**
* Add to a value at a given index in the array
* @param index The index of value to add to
* @param valueToAdd The amount to add to the value at the given index
* @throws ArrayIndexOutOfBoundsException (may throw) if value is exceeds length()
*/
public void add(final int index, final long valueToAdd) throws ArrayIndexOutOfBoundsException {
long criticalValueAtEnter = recordingPhaser.writerCriticalSectionEnter();
try {
activeArray.add(index, valueToAdd);
} finally {
recordingPhaser.writerCriticalSectionExit(criticalValueAtEnter);
}
}
/**
* Get an interval array, which will include a stable, consistent view of all values
* accumulated since the last interval array was taken.
* <p>
* Calling this method is equivalent to calling {@code getIntervalArray(null)}. It is generally recommended
* that the {@link PackedArraySingleWriterRecorder#getIntervalArray(PackedLongArray arrayToRecycle)
* getIntervalHistogram(arrayToRecycle)} orm be used for
* regular interval array sampling, as that form accepts a previously returned interval array that can be
* recycled internally to avoid allocation and content copying operations, and is therefore significantly
* more efficient for repeated use than {@link PackedArraySingleWriterRecorder#getIntervalArray()}.
* <p>
* Calling {@link PackedArraySingleWriterRecorder#getIntervalArray()} will reset the values at
* all indexes of the array tracked by the recorder, and start accumulating values for the next interval.
*
* @return an array containing the values accumulated since the last interval array was taken.
*/
public synchronized PackedLongArray getIntervalArray() {<FILL_FUNCTION_BODY>}
/**
* Get an interval array, which will include a stable, consistent view of all values
* accumulated since the last interval array was taken.
* <p>
* {@link PackedArraySingleWriterRecorder#getIntervalArray(PackedLongArray arrayToRecycle)
* getIntervalArray(arrayToRecycle)}
* accepts a previously returned interval array that can be recycled internally to avoid allocation
* and content copying operations, and is therefore significantly more efficient for repeated use than
* {@link PackedArraySingleWriterRecorder#getIntervalArray()}. The provided {@code arrayToRecycle} must
* be either be null or an interval array returned by a previous call to
* {@link PackedArraySingleWriterRecorder#getIntervalArray(PackedLongArray arrayToRecycle)
* getIntervalArray(arrayToRecycle)} or
* {@link PackedArraySingleWriterRecorder#getIntervalArray()}.
* <p>
* NOTE: The caller is responsible for not recycling the same returned interval array more than once. If
* the same interval array instance is recycled more than once, behavior is undefined.
* <p>
* Calling {@link PackedArraySingleWriterRecorder#getIntervalArray(PackedLongArray arrayToRecycle)
* getIntervalArray(arrayToRecycle)} will reset the values at all indexes of the array
* tracked by the recorder, and start accumulating values for the next interval.
*
* @param arrayToRecycle a previously returned interval array (from this instance of
* {@link PackedArraySingleWriterRecorder}) that may be recycled to avoid allocation and
* copy operations.
* @return an array containing the values accumulated since the last interval array was taken.
*/
public synchronized PackedLongArray getIntervalArray(final PackedLongArray arrayToRecycle) {
return getIntervalArray(arrayToRecycle, true);
}
/**
* Get an interval array, which will include a stable, consistent view of all values
* accumulated since the last interval array was taken.
* <p>
* {@link PackedArraySingleWriterRecorder#getIntervalArray(PackedLongArray arrayToRecycle)
* getIntervalArray(arrayToRecycle)}
* accepts a previously returned interval array that can be recycled internally to avoid allocation
* and content copying operations, and is therefore significantly more efficient for repeated use than
* {@link PackedArraySingleWriterRecorder#getIntervalArray()}. The provided {@code arrayToRecycle} must
* be either be null or an interval array returned by a previous call to
* {@link PackedArraySingleWriterRecorder#getIntervalArray(PackedLongArray arrayToRecycle)
* getIntervalArray(arrayToRecycle)} or
* {@link PackedArraySingleWriterRecorder#getIntervalArray()}.
* <p>
* NOTE: The caller is responsible for not recycling the same returned interval array more than once. If
* the same interval array instance is recycled more than once, behavior is undefined.
* <p>
* Calling {@link PackedArraySingleWriterRecorder#getIntervalArray(PackedLongArray arrayToRecycle)
* getIntervalArray(arrayToRecycle, enforeContainingInstance)} will reset the values at all indexes
* of the array tracked by the recorder, and start accumulating values for the next interval.
*
* @param arrayToRecycle a previously returned interval array that may be recycled to avoid allocation and
* copy operations.
* @param enforceContainingInstance if true, will only allow recycling of arrays previously returned from this
* instance of {@link PackedArraySingleWriterRecorder}. If false, will allow recycling arrays
* previously returned by other instances of {@link PackedArraySingleWriterRecorder}.
* @return an array containing the values accumulated since the last interval array was taken.
*/
public synchronized PackedLongArray getIntervalArray(final PackedLongArray arrayToRecycle,
final boolean enforceContainingInstance) {
// Verify that replacement array can validly be used as an inactive array replacement:
validateFitAsReplacementArray(arrayToRecycle, enforceContainingInstance);
PackedLongArray sampledArray = performIntervalSample(arrayToRecycle);
return sampledArray;
}
/**
* Reset the array contents to all zeros.
*/
public synchronized void reset() {
// the currently active array is reset each time we flip:
performIntervalSample(null);
}
private PackedLongArray performIntervalSample(final PackedLongArray arrayToRecycle) {
PackedLongArray inactiveArray = arrayToRecycle;
try {
recordingPhaser.readerLock();
// Make sure we have an inactive version to flip in:
if (inactiveArray == null) {
if (activeArray instanceof InternalPackedLongArray) {
inactiveArray = new InternalPackedLongArray(instanceId, activeArray.length());
} else {
throw new IllegalStateException("Unexpected internal array type for activeArray");
}
} else {
inactiveArray.clear();
}
// Swap active and inactive arrays:
final PackedLongArray tempArray = inactiveArray;
inactiveArray = activeArray;
activeArray = tempArray;
// Mark end time of previous interval and start time of new one:
long now = System.currentTimeMillis();
activeArray.setStartTimeStamp(now);
inactiveArray.setEndTimeStamp(now);
// Make sure we are not in the middle of recording a value on the previously active array:
// Flip phase to make sure no recordings that were in flight pre-flip are still active:
recordingPhaser.flipPhase(500000L /* yield in 0.5 msec units if needed */);
} finally {
recordingPhaser.readerUnlock();
}
return inactiveArray;
}
private static class InternalPackedLongArray extends PackedLongArray {
private final long containingInstanceId;
private InternalPackedLongArray(final long id, int virtualLength, final int initialPhysicalLength) {
super(virtualLength, initialPhysicalLength);
this.containingInstanceId = id;
}
private InternalPackedLongArray(final long id, final int virtualLength) {
super(virtualLength);
this.containingInstanceId = id;
}
}
private void validateFitAsReplacementArray(final PackedLongArray replacementArray,
final boolean enforceContainingInstance) {
boolean bad = true;
if (replacementArray == null) {
bad = false;
} else if (replacementArray instanceof InternalPackedLongArray) {
if ((activeArray instanceof InternalPackedLongArray)
&&
((!enforceContainingInstance) ||
(((InternalPackedLongArray)replacementArray).containingInstanceId ==
((InternalPackedLongArray) activeArray).containingInstanceId)
)) {
bad = false;
}
}
if (bad) {
throw new IllegalArgumentException("replacement array must have been obtained via a previous" +
" getIntervalArray() call from this " + this.getClass().getName() +
(enforceContainingInstance ? " instance" : " class"));
}
}
} |
return getIntervalArray(null);
|
HdrHistogram_HdrHistogram | HdrHistogram/src/main/java/org/HdrHistogram/packedarray/PackedArraySingleWriterRecorder.java | PackedArraySingleWriterRecorder | getIntervalArray | class PackedArraySingleWriterRecorder {
private static final AtomicLong instanceIdSequencer = new AtomicLong(1);
private final long instanceId = instanceIdSequencer.getAndIncrement();
private final WriterReaderPhaser recordingPhaser = new WriterReaderPhaser();
private volatile PackedLongArray activeArray;
/**
* Construct a {@link PackedArraySingleWriterRecorder} with a given (virtual) array length.
*
* @param virtualLength The (virtual) array length
*/
public PackedArraySingleWriterRecorder(final int virtualLength) {
activeArray = new InternalPackedLongArray(instanceId, virtualLength);
activeArray.setStartTimeStamp(System.currentTimeMillis());
}
/**
* Construct a {@link PackedArraySingleWriterRecorder} with a given (virtual) array length, starting with a given
* initial physical backing store length
*
* @param virtualLength The (virtual) array length
* @param initialPhysicalLength The initial physical backing store length
*/
public PackedArraySingleWriterRecorder(final int virtualLength, final int initialPhysicalLength) {
activeArray = new InternalPackedLongArray(instanceId, virtualLength, initialPhysicalLength);
activeArray.setStartTimeStamp(System.currentTimeMillis());
}
/**
* Returns the virtual length of the array represented by this recorder
* @return The virtual length of the array represented by this recorder
*/
public int length() {
return activeArray.length();
}
/**
* Change the (virtual) length of the array represented by the this recorder
* @param newVirtualLength the new (virtual) length to use
*/
public void setVirtualLength(int newVirtualLength) {
try {
recordingPhaser.readerLock();
// We don't care about concurrent modifications to the array, as setVirtualLength() in the
// ConcurrentPackedLongArray takes care of those. However, we must perform the change of virtual
// length under the recorder's readerLock protection to prevent mid-change observations:
activeArray.setVirtualLength(newVirtualLength);
} finally {
recordingPhaser.readerUnlock();
}
}
/**
* Increment a value at a given index in the array
* @param index the index of the value to be incremented
* @throws ArrayIndexOutOfBoundsException (may throw) if value is exceeds length()
*/
public void increment(final int index) throws ArrayIndexOutOfBoundsException {
long criticalValueAtEnter = recordingPhaser.writerCriticalSectionEnter();
try {
activeArray.increment(index);
} finally {
recordingPhaser.writerCriticalSectionExit(criticalValueAtEnter);
}
}
/**
* Add to a value at a given index in the array
* @param index The index of value to add to
* @param valueToAdd The amount to add to the value at the given index
* @throws ArrayIndexOutOfBoundsException (may throw) if value is exceeds length()
*/
public void add(final int index, final long valueToAdd) throws ArrayIndexOutOfBoundsException {
long criticalValueAtEnter = recordingPhaser.writerCriticalSectionEnter();
try {
activeArray.add(index, valueToAdd);
} finally {
recordingPhaser.writerCriticalSectionExit(criticalValueAtEnter);
}
}
/**
* Get an interval array, which will include a stable, consistent view of all values
* accumulated since the last interval array was taken.
* <p>
* Calling this method is equivalent to calling {@code getIntervalArray(null)}. It is generally recommended
* that the {@link PackedArraySingleWriterRecorder#getIntervalArray(PackedLongArray arrayToRecycle)
* getIntervalHistogram(arrayToRecycle)} orm be used for
* regular interval array sampling, as that form accepts a previously returned interval array that can be
* recycled internally to avoid allocation and content copying operations, and is therefore significantly
* more efficient for repeated use than {@link PackedArraySingleWriterRecorder#getIntervalArray()}.
* <p>
* Calling {@link PackedArraySingleWriterRecorder#getIntervalArray()} will reset the values at
* all indexes of the array tracked by the recorder, and start accumulating values for the next interval.
*
* @return an array containing the values accumulated since the last interval array was taken.
*/
public synchronized PackedLongArray getIntervalArray() {
return getIntervalArray(null);
}
/**
* Get an interval array, which will include a stable, consistent view of all values
* accumulated since the last interval array was taken.
* <p>
* {@link PackedArraySingleWriterRecorder#getIntervalArray(PackedLongArray arrayToRecycle)
* getIntervalArray(arrayToRecycle)}
* accepts a previously returned interval array that can be recycled internally to avoid allocation
* and content copying operations, and is therefore significantly more efficient for repeated use than
* {@link PackedArraySingleWriterRecorder#getIntervalArray()}. The provided {@code arrayToRecycle} must
* be either be null or an interval array returned by a previous call to
* {@link PackedArraySingleWriterRecorder#getIntervalArray(PackedLongArray arrayToRecycle)
* getIntervalArray(arrayToRecycle)} or
* {@link PackedArraySingleWriterRecorder#getIntervalArray()}.
* <p>
* NOTE: The caller is responsible for not recycling the same returned interval array more than once. If
* the same interval array instance is recycled more than once, behavior is undefined.
* <p>
* Calling {@link PackedArraySingleWriterRecorder#getIntervalArray(PackedLongArray arrayToRecycle)
* getIntervalArray(arrayToRecycle)} will reset the values at all indexes of the array
* tracked by the recorder, and start accumulating values for the next interval.
*
* @param arrayToRecycle a previously returned interval array (from this instance of
* {@link PackedArraySingleWriterRecorder}) that may be recycled to avoid allocation and
* copy operations.
* @return an array containing the values accumulated since the last interval array was taken.
*/
public synchronized PackedLongArray getIntervalArray(final PackedLongArray arrayToRecycle) {<FILL_FUNCTION_BODY>}
/**
* Get an interval array, which will include a stable, consistent view of all values
* accumulated since the last interval array was taken.
* <p>
* {@link PackedArraySingleWriterRecorder#getIntervalArray(PackedLongArray arrayToRecycle)
* getIntervalArray(arrayToRecycle)}
* accepts a previously returned interval array that can be recycled internally to avoid allocation
* and content copying operations, and is therefore significantly more efficient for repeated use than
* {@link PackedArraySingleWriterRecorder#getIntervalArray()}. The provided {@code arrayToRecycle} must
* be either be null or an interval array returned by a previous call to
* {@link PackedArraySingleWriterRecorder#getIntervalArray(PackedLongArray arrayToRecycle)
* getIntervalArray(arrayToRecycle)} or
* {@link PackedArraySingleWriterRecorder#getIntervalArray()}.
* <p>
* NOTE: The caller is responsible for not recycling the same returned interval array more than once. If
* the same interval array instance is recycled more than once, behavior is undefined.
* <p>
* Calling {@link PackedArraySingleWriterRecorder#getIntervalArray(PackedLongArray arrayToRecycle)
* getIntervalArray(arrayToRecycle, enforeContainingInstance)} will reset the values at all indexes
* of the array tracked by the recorder, and start accumulating values for the next interval.
*
* @param arrayToRecycle a previously returned interval array that may be recycled to avoid allocation and
* copy operations.
* @param enforceContainingInstance if true, will only allow recycling of arrays previously returned from this
* instance of {@link PackedArraySingleWriterRecorder}. If false, will allow recycling arrays
* previously returned by other instances of {@link PackedArraySingleWriterRecorder}.
* @return an array containing the values accumulated since the last interval array was taken.
*/
public synchronized PackedLongArray getIntervalArray(final PackedLongArray arrayToRecycle,
final boolean enforceContainingInstance) {
// Verify that replacement array can validly be used as an inactive array replacement:
validateFitAsReplacementArray(arrayToRecycle, enforceContainingInstance);
PackedLongArray sampledArray = performIntervalSample(arrayToRecycle);
return sampledArray;
}
/**
* Reset the array contents to all zeros.
*/
public synchronized void reset() {
// the currently active array is reset each time we flip:
performIntervalSample(null);
}
private PackedLongArray performIntervalSample(final PackedLongArray arrayToRecycle) {
PackedLongArray inactiveArray = arrayToRecycle;
try {
recordingPhaser.readerLock();
// Make sure we have an inactive version to flip in:
if (inactiveArray == null) {
if (activeArray instanceof InternalPackedLongArray) {
inactiveArray = new InternalPackedLongArray(instanceId, activeArray.length());
} else {
throw new IllegalStateException("Unexpected internal array type for activeArray");
}
} else {
inactiveArray.clear();
}
// Swap active and inactive arrays:
final PackedLongArray tempArray = inactiveArray;
inactiveArray = activeArray;
activeArray = tempArray;
// Mark end time of previous interval and start time of new one:
long now = System.currentTimeMillis();
activeArray.setStartTimeStamp(now);
inactiveArray.setEndTimeStamp(now);
// Make sure we are not in the middle of recording a value on the previously active array:
// Flip phase to make sure no recordings that were in flight pre-flip are still active:
recordingPhaser.flipPhase(500000L /* yield in 0.5 msec units if needed */);
} finally {
recordingPhaser.readerUnlock();
}
return inactiveArray;
}
private static class InternalPackedLongArray extends PackedLongArray {
private final long containingInstanceId;
private InternalPackedLongArray(final long id, int virtualLength, final int initialPhysicalLength) {
super(virtualLength, initialPhysicalLength);
this.containingInstanceId = id;
}
private InternalPackedLongArray(final long id, final int virtualLength) {
super(virtualLength);
this.containingInstanceId = id;
}
}
private void validateFitAsReplacementArray(final PackedLongArray replacementArray,
final boolean enforceContainingInstance) {
boolean bad = true;
if (replacementArray == null) {
bad = false;
} else if (replacementArray instanceof InternalPackedLongArray) {
if ((activeArray instanceof InternalPackedLongArray)
&&
((!enforceContainingInstance) ||
(((InternalPackedLongArray)replacementArray).containingInstanceId ==
((InternalPackedLongArray) activeArray).containingInstanceId)
)) {
bad = false;
}
}
if (bad) {
throw new IllegalArgumentException("replacement array must have been obtained via a previous" +
" getIntervalArray() call from this " + this.getClass().getName() +
(enforceContainingInstance ? " instance" : " class"));
}
}
} |
return getIntervalArray(arrayToRecycle, true);
|
HdrHistogram_HdrHistogram | HdrHistogram/src/main/java/org/HdrHistogram/packedarray/PackedArraySingleWriterRecorder.java | PackedArraySingleWriterRecorder | getIntervalArray | class PackedArraySingleWriterRecorder {
private static final AtomicLong instanceIdSequencer = new AtomicLong(1);
private final long instanceId = instanceIdSequencer.getAndIncrement();
private final WriterReaderPhaser recordingPhaser = new WriterReaderPhaser();
private volatile PackedLongArray activeArray;
/**
* Construct a {@link PackedArraySingleWriterRecorder} with a given (virtual) array length.
*
* @param virtualLength The (virtual) array length
*/
public PackedArraySingleWriterRecorder(final int virtualLength) {
activeArray = new InternalPackedLongArray(instanceId, virtualLength);
activeArray.setStartTimeStamp(System.currentTimeMillis());
}
/**
* Construct a {@link PackedArraySingleWriterRecorder} with a given (virtual) array length, starting with a given
* initial physical backing store length
*
* @param virtualLength The (virtual) array length
* @param initialPhysicalLength The initial physical backing store length
*/
public PackedArraySingleWriterRecorder(final int virtualLength, final int initialPhysicalLength) {
activeArray = new InternalPackedLongArray(instanceId, virtualLength, initialPhysicalLength);
activeArray.setStartTimeStamp(System.currentTimeMillis());
}
/**
* Returns the virtual length of the array represented by this recorder
* @return The virtual length of the array represented by this recorder
*/
public int length() {
return activeArray.length();
}
/**
* Change the (virtual) length of the array represented by the this recorder
* @param newVirtualLength the new (virtual) length to use
*/
public void setVirtualLength(int newVirtualLength) {
try {
recordingPhaser.readerLock();
// We don't care about concurrent modifications to the array, as setVirtualLength() in the
// ConcurrentPackedLongArray takes care of those. However, we must perform the change of virtual
// length under the recorder's readerLock protection to prevent mid-change observations:
activeArray.setVirtualLength(newVirtualLength);
} finally {
recordingPhaser.readerUnlock();
}
}
/**
* Increment a value at a given index in the array
* @param index the index of the value to be incremented
* @throws ArrayIndexOutOfBoundsException (may throw) if value is exceeds length()
*/
public void increment(final int index) throws ArrayIndexOutOfBoundsException {
long criticalValueAtEnter = recordingPhaser.writerCriticalSectionEnter();
try {
activeArray.increment(index);
} finally {
recordingPhaser.writerCriticalSectionExit(criticalValueAtEnter);
}
}
/**
* Add to a value at a given index in the array
* @param index The index of value to add to
* @param valueToAdd The amount to add to the value at the given index
* @throws ArrayIndexOutOfBoundsException (may throw) if value is exceeds length()
*/
public void add(final int index, final long valueToAdd) throws ArrayIndexOutOfBoundsException {
long criticalValueAtEnter = recordingPhaser.writerCriticalSectionEnter();
try {
activeArray.add(index, valueToAdd);
} finally {
recordingPhaser.writerCriticalSectionExit(criticalValueAtEnter);
}
}
/**
* Get an interval array, which will include a stable, consistent view of all values
* accumulated since the last interval array was taken.
* <p>
* Calling this method is equivalent to calling {@code getIntervalArray(null)}. It is generally recommended
* that the {@link PackedArraySingleWriterRecorder#getIntervalArray(PackedLongArray arrayToRecycle)
* getIntervalHistogram(arrayToRecycle)} orm be used for
* regular interval array sampling, as that form accepts a previously returned interval array that can be
* recycled internally to avoid allocation and content copying operations, and is therefore significantly
* more efficient for repeated use than {@link PackedArraySingleWriterRecorder#getIntervalArray()}.
* <p>
* Calling {@link PackedArraySingleWriterRecorder#getIntervalArray()} will reset the values at
* all indexes of the array tracked by the recorder, and start accumulating values for the next interval.
*
* @return an array containing the values accumulated since the last interval array was taken.
*/
public synchronized PackedLongArray getIntervalArray() {
return getIntervalArray(null);
}
/**
* Get an interval array, which will include a stable, consistent view of all values
* accumulated since the last interval array was taken.
* <p>
* {@link PackedArraySingleWriterRecorder#getIntervalArray(PackedLongArray arrayToRecycle)
* getIntervalArray(arrayToRecycle)}
* accepts a previously returned interval array that can be recycled internally to avoid allocation
* and content copying operations, and is therefore significantly more efficient for repeated use than
* {@link PackedArraySingleWriterRecorder#getIntervalArray()}. The provided {@code arrayToRecycle} must
* be either be null or an interval array returned by a previous call to
* {@link PackedArraySingleWriterRecorder#getIntervalArray(PackedLongArray arrayToRecycle)
* getIntervalArray(arrayToRecycle)} or
* {@link PackedArraySingleWriterRecorder#getIntervalArray()}.
* <p>
* NOTE: The caller is responsible for not recycling the same returned interval array more than once. If
* the same interval array instance is recycled more than once, behavior is undefined.
* <p>
* Calling {@link PackedArraySingleWriterRecorder#getIntervalArray(PackedLongArray arrayToRecycle)
* getIntervalArray(arrayToRecycle)} will reset the values at all indexes of the array
* tracked by the recorder, and start accumulating values for the next interval.
*
* @param arrayToRecycle a previously returned interval array (from this instance of
* {@link PackedArraySingleWriterRecorder}) that may be recycled to avoid allocation and
* copy operations.
* @return an array containing the values accumulated since the last interval array was taken.
*/
public synchronized PackedLongArray getIntervalArray(final PackedLongArray arrayToRecycle) {
return getIntervalArray(arrayToRecycle, true);
}
/**
* Get an interval array, which will include a stable, consistent view of all values
* accumulated since the last interval array was taken.
* <p>
* {@link PackedArraySingleWriterRecorder#getIntervalArray(PackedLongArray arrayToRecycle)
* getIntervalArray(arrayToRecycle)}
* accepts a previously returned interval array that can be recycled internally to avoid allocation
* and content copying operations, and is therefore significantly more efficient for repeated use than
* {@link PackedArraySingleWriterRecorder#getIntervalArray()}. The provided {@code arrayToRecycle} must
* be either be null or an interval array returned by a previous call to
* {@link PackedArraySingleWriterRecorder#getIntervalArray(PackedLongArray arrayToRecycle)
* getIntervalArray(arrayToRecycle)} or
* {@link PackedArraySingleWriterRecorder#getIntervalArray()}.
* <p>
* NOTE: The caller is responsible for not recycling the same returned interval array more than once. If
* the same interval array instance is recycled more than once, behavior is undefined.
* <p>
* Calling {@link PackedArraySingleWriterRecorder#getIntervalArray(PackedLongArray arrayToRecycle)
* getIntervalArray(arrayToRecycle, enforeContainingInstance)} will reset the values at all indexes
* of the array tracked by the recorder, and start accumulating values for the next interval.
*
* @param arrayToRecycle a previously returned interval array that may be recycled to avoid allocation and
* copy operations.
* @param enforceContainingInstance if true, will only allow recycling of arrays previously returned from this
* instance of {@link PackedArraySingleWriterRecorder}. If false, will allow recycling arrays
* previously returned by other instances of {@link PackedArraySingleWriterRecorder}.
* @return an array containing the values accumulated since the last interval array was taken.
*/
public synchronized PackedLongArray getIntervalArray(final PackedLongArray arrayToRecycle,
final boolean enforceContainingInstance) {<FILL_FUNCTION_BODY>}
/**
* Reset the array contents to all zeros.
*/
public synchronized void reset() {
// the currently active array is reset each time we flip:
performIntervalSample(null);
}
private PackedLongArray performIntervalSample(final PackedLongArray arrayToRecycle) {
PackedLongArray inactiveArray = arrayToRecycle;
try {
recordingPhaser.readerLock();
// Make sure we have an inactive version to flip in:
if (inactiveArray == null) {
if (activeArray instanceof InternalPackedLongArray) {
inactiveArray = new InternalPackedLongArray(instanceId, activeArray.length());
} else {
throw new IllegalStateException("Unexpected internal array type for activeArray");
}
} else {
inactiveArray.clear();
}
// Swap active and inactive arrays:
final PackedLongArray tempArray = inactiveArray;
inactiveArray = activeArray;
activeArray = tempArray;
// Mark end time of previous interval and start time of new one:
long now = System.currentTimeMillis();
activeArray.setStartTimeStamp(now);
inactiveArray.setEndTimeStamp(now);
// Make sure we are not in the middle of recording a value on the previously active array:
// Flip phase to make sure no recordings that were in flight pre-flip are still active:
recordingPhaser.flipPhase(500000L /* yield in 0.5 msec units if needed */);
} finally {
recordingPhaser.readerUnlock();
}
return inactiveArray;
}
private static class InternalPackedLongArray extends PackedLongArray {
private final long containingInstanceId;
private InternalPackedLongArray(final long id, int virtualLength, final int initialPhysicalLength) {
super(virtualLength, initialPhysicalLength);
this.containingInstanceId = id;
}
private InternalPackedLongArray(final long id, final int virtualLength) {
super(virtualLength);
this.containingInstanceId = id;
}
}
private void validateFitAsReplacementArray(final PackedLongArray replacementArray,
final boolean enforceContainingInstance) {
boolean bad = true;
if (replacementArray == null) {
bad = false;
} else if (replacementArray instanceof InternalPackedLongArray) {
if ((activeArray instanceof InternalPackedLongArray)
&&
((!enforceContainingInstance) ||
(((InternalPackedLongArray)replacementArray).containingInstanceId ==
((InternalPackedLongArray) activeArray).containingInstanceId)
)) {
bad = false;
}
}
if (bad) {
throw new IllegalArgumentException("replacement array must have been obtained via a previous" +
" getIntervalArray() call from this " + this.getClass().getName() +
(enforceContainingInstance ? " instance" : " class"));
}
}
} |
// Verify that replacement array can validly be used as an inactive array replacement:
validateFitAsReplacementArray(arrayToRecycle, enforceContainingInstance);
PackedLongArray sampledArray = performIntervalSample(arrayToRecycle);
return sampledArray;
|
HdrHistogram_HdrHistogram | HdrHistogram/src/main/java/org/HdrHistogram/packedarray/PackedArraySingleWriterRecorder.java | PackedArraySingleWriterRecorder | reset | class PackedArraySingleWriterRecorder {
private static final AtomicLong instanceIdSequencer = new AtomicLong(1);
private final long instanceId = instanceIdSequencer.getAndIncrement();
private final WriterReaderPhaser recordingPhaser = new WriterReaderPhaser();
private volatile PackedLongArray activeArray;
/**
* Construct a {@link PackedArraySingleWriterRecorder} with a given (virtual) array length.
*
* @param virtualLength The (virtual) array length
*/
public PackedArraySingleWriterRecorder(final int virtualLength) {
activeArray = new InternalPackedLongArray(instanceId, virtualLength);
activeArray.setStartTimeStamp(System.currentTimeMillis());
}
/**
* Construct a {@link PackedArraySingleWriterRecorder} with a given (virtual) array length, starting with a given
* initial physical backing store length
*
* @param virtualLength The (virtual) array length
* @param initialPhysicalLength The initial physical backing store length
*/
public PackedArraySingleWriterRecorder(final int virtualLength, final int initialPhysicalLength) {
activeArray = new InternalPackedLongArray(instanceId, virtualLength, initialPhysicalLength);
activeArray.setStartTimeStamp(System.currentTimeMillis());
}
/**
* Returns the virtual length of the array represented by this recorder
* @return The virtual length of the array represented by this recorder
*/
public int length() {
return activeArray.length();
}
/**
* Change the (virtual) length of the array represented by the this recorder
* @param newVirtualLength the new (virtual) length to use
*/
public void setVirtualLength(int newVirtualLength) {
try {
recordingPhaser.readerLock();
// We don't care about concurrent modifications to the array, as setVirtualLength() in the
// ConcurrentPackedLongArray takes care of those. However, we must perform the change of virtual
// length under the recorder's readerLock protection to prevent mid-change observations:
activeArray.setVirtualLength(newVirtualLength);
} finally {
recordingPhaser.readerUnlock();
}
}
/**
* Increment a value at a given index in the array
* @param index the index of the value to be incremented
* @throws ArrayIndexOutOfBoundsException (may throw) if value is exceeds length()
*/
public void increment(final int index) throws ArrayIndexOutOfBoundsException {
long criticalValueAtEnter = recordingPhaser.writerCriticalSectionEnter();
try {
activeArray.increment(index);
} finally {
recordingPhaser.writerCriticalSectionExit(criticalValueAtEnter);
}
}
/**
* Add to a value at a given index in the array
* @param index The index of value to add to
* @param valueToAdd The amount to add to the value at the given index
* @throws ArrayIndexOutOfBoundsException (may throw) if value is exceeds length()
*/
public void add(final int index, final long valueToAdd) throws ArrayIndexOutOfBoundsException {
long criticalValueAtEnter = recordingPhaser.writerCriticalSectionEnter();
try {
activeArray.add(index, valueToAdd);
} finally {
recordingPhaser.writerCriticalSectionExit(criticalValueAtEnter);
}
}
/**
* Get an interval array, which will include a stable, consistent view of all values
* accumulated since the last interval array was taken.
* <p>
* Calling this method is equivalent to calling {@code getIntervalArray(null)}. It is generally recommended
* that the {@link PackedArraySingleWriterRecorder#getIntervalArray(PackedLongArray arrayToRecycle)
* getIntervalHistogram(arrayToRecycle)} orm be used for
* regular interval array sampling, as that form accepts a previously returned interval array that can be
* recycled internally to avoid allocation and content copying operations, and is therefore significantly
* more efficient for repeated use than {@link PackedArraySingleWriterRecorder#getIntervalArray()}.
* <p>
* Calling {@link PackedArraySingleWriterRecorder#getIntervalArray()} will reset the values at
* all indexes of the array tracked by the recorder, and start accumulating values for the next interval.
*
* @return an array containing the values accumulated since the last interval array was taken.
*/
public synchronized PackedLongArray getIntervalArray() {
return getIntervalArray(null);
}
/**
* Get an interval array, which will include a stable, consistent view of all values
* accumulated since the last interval array was taken.
* <p>
* {@link PackedArraySingleWriterRecorder#getIntervalArray(PackedLongArray arrayToRecycle)
* getIntervalArray(arrayToRecycle)}
* accepts a previously returned interval array that can be recycled internally to avoid allocation
* and content copying operations, and is therefore significantly more efficient for repeated use than
* {@link PackedArraySingleWriterRecorder#getIntervalArray()}. The provided {@code arrayToRecycle} must
* be either be null or an interval array returned by a previous call to
* {@link PackedArraySingleWriterRecorder#getIntervalArray(PackedLongArray arrayToRecycle)
* getIntervalArray(arrayToRecycle)} or
* {@link PackedArraySingleWriterRecorder#getIntervalArray()}.
* <p>
* NOTE: The caller is responsible for not recycling the same returned interval array more than once. If
* the same interval array instance is recycled more than once, behavior is undefined.
* <p>
* Calling {@link PackedArraySingleWriterRecorder#getIntervalArray(PackedLongArray arrayToRecycle)
* getIntervalArray(arrayToRecycle)} will reset the values at all indexes of the array
* tracked by the recorder, and start accumulating values for the next interval.
*
* @param arrayToRecycle a previously returned interval array (from this instance of
* {@link PackedArraySingleWriterRecorder}) that may be recycled to avoid allocation and
* copy operations.
* @return an array containing the values accumulated since the last interval array was taken.
*/
public synchronized PackedLongArray getIntervalArray(final PackedLongArray arrayToRecycle) {
return getIntervalArray(arrayToRecycle, true);
}
/**
* Get an interval array, which will include a stable, consistent view of all values
* accumulated since the last interval array was taken.
* <p>
* {@link PackedArraySingleWriterRecorder#getIntervalArray(PackedLongArray arrayToRecycle)
* getIntervalArray(arrayToRecycle)}
* accepts a previously returned interval array that can be recycled internally to avoid allocation
* and content copying operations, and is therefore significantly more efficient for repeated use than
* {@link PackedArraySingleWriterRecorder#getIntervalArray()}. The provided {@code arrayToRecycle} must
* be either be null or an interval array returned by a previous call to
* {@link PackedArraySingleWriterRecorder#getIntervalArray(PackedLongArray arrayToRecycle)
* getIntervalArray(arrayToRecycle)} or
* {@link PackedArraySingleWriterRecorder#getIntervalArray()}.
* <p>
* NOTE: The caller is responsible for not recycling the same returned interval array more than once. If
* the same interval array instance is recycled more than once, behavior is undefined.
* <p>
* Calling {@link PackedArraySingleWriterRecorder#getIntervalArray(PackedLongArray arrayToRecycle)
* getIntervalArray(arrayToRecycle, enforeContainingInstance)} will reset the values at all indexes
* of the array tracked by the recorder, and start accumulating values for the next interval.
*
* @param arrayToRecycle a previously returned interval array that may be recycled to avoid allocation and
* copy operations.
* @param enforceContainingInstance if true, will only allow recycling of arrays previously returned from this
* instance of {@link PackedArraySingleWriterRecorder}. If false, will allow recycling arrays
* previously returned by other instances of {@link PackedArraySingleWriterRecorder}.
* @return an array containing the values accumulated since the last interval array was taken.
*/
public synchronized PackedLongArray getIntervalArray(final PackedLongArray arrayToRecycle,
final boolean enforceContainingInstance) {
// Verify that replacement array can validly be used as an inactive array replacement:
validateFitAsReplacementArray(arrayToRecycle, enforceContainingInstance);
PackedLongArray sampledArray = performIntervalSample(arrayToRecycle);
return sampledArray;
}
/**
* Reset the array contents to all zeros.
*/
public synchronized void reset() {<FILL_FUNCTION_BODY>}
private PackedLongArray performIntervalSample(final PackedLongArray arrayToRecycle) {
PackedLongArray inactiveArray = arrayToRecycle;
try {
recordingPhaser.readerLock();
// Make sure we have an inactive version to flip in:
if (inactiveArray == null) {
if (activeArray instanceof InternalPackedLongArray) {
inactiveArray = new InternalPackedLongArray(instanceId, activeArray.length());
} else {
throw new IllegalStateException("Unexpected internal array type for activeArray");
}
} else {
inactiveArray.clear();
}
// Swap active and inactive arrays:
final PackedLongArray tempArray = inactiveArray;
inactiveArray = activeArray;
activeArray = tempArray;
// Mark end time of previous interval and start time of new one:
long now = System.currentTimeMillis();
activeArray.setStartTimeStamp(now);
inactiveArray.setEndTimeStamp(now);
// Make sure we are not in the middle of recording a value on the previously active array:
// Flip phase to make sure no recordings that were in flight pre-flip are still active:
recordingPhaser.flipPhase(500000L /* yield in 0.5 msec units if needed */);
} finally {
recordingPhaser.readerUnlock();
}
return inactiveArray;
}
private static class InternalPackedLongArray extends PackedLongArray {
private final long containingInstanceId;
private InternalPackedLongArray(final long id, int virtualLength, final int initialPhysicalLength) {
super(virtualLength, initialPhysicalLength);
this.containingInstanceId = id;
}
private InternalPackedLongArray(final long id, final int virtualLength) {
super(virtualLength);
this.containingInstanceId = id;
}
}
private void validateFitAsReplacementArray(final PackedLongArray replacementArray,
final boolean enforceContainingInstance) {
boolean bad = true;
if (replacementArray == null) {
bad = false;
} else if (replacementArray instanceof InternalPackedLongArray) {
if ((activeArray instanceof InternalPackedLongArray)
&&
((!enforceContainingInstance) ||
(((InternalPackedLongArray)replacementArray).containingInstanceId ==
((InternalPackedLongArray) activeArray).containingInstanceId)
)) {
bad = false;
}
}
if (bad) {
throw new IllegalArgumentException("replacement array must have been obtained via a previous" +
" getIntervalArray() call from this " + this.getClass().getName() +
(enforceContainingInstance ? " instance" : " class"));
}
}
} |
// the currently active array is reset each time we flip:
performIntervalSample(null);
|
HdrHistogram_HdrHistogram | HdrHistogram/src/main/java/org/HdrHistogram/packedarray/PackedArraySingleWriterRecorder.java | PackedArraySingleWriterRecorder | performIntervalSample | class PackedArraySingleWriterRecorder {
private static final AtomicLong instanceIdSequencer = new AtomicLong(1);
private final long instanceId = instanceIdSequencer.getAndIncrement();
private final WriterReaderPhaser recordingPhaser = new WriterReaderPhaser();
private volatile PackedLongArray activeArray;
/**
* Construct a {@link PackedArraySingleWriterRecorder} with a given (virtual) array length.
*
* @param virtualLength The (virtual) array length
*/
public PackedArraySingleWriterRecorder(final int virtualLength) {
activeArray = new InternalPackedLongArray(instanceId, virtualLength);
activeArray.setStartTimeStamp(System.currentTimeMillis());
}
/**
* Construct a {@link PackedArraySingleWriterRecorder} with a given (virtual) array length, starting with a given
* initial physical backing store length
*
* @param virtualLength The (virtual) array length
* @param initialPhysicalLength The initial physical backing store length
*/
public PackedArraySingleWriterRecorder(final int virtualLength, final int initialPhysicalLength) {
activeArray = new InternalPackedLongArray(instanceId, virtualLength, initialPhysicalLength);
activeArray.setStartTimeStamp(System.currentTimeMillis());
}
/**
* Returns the virtual length of the array represented by this recorder
* @return The virtual length of the array represented by this recorder
*/
public int length() {
return activeArray.length();
}
/**
* Change the (virtual) length of the array represented by the this recorder
* @param newVirtualLength the new (virtual) length to use
*/
public void setVirtualLength(int newVirtualLength) {
try {
recordingPhaser.readerLock();
// We don't care about concurrent modifications to the array, as setVirtualLength() in the
// ConcurrentPackedLongArray takes care of those. However, we must perform the change of virtual
// length under the recorder's readerLock protection to prevent mid-change observations:
activeArray.setVirtualLength(newVirtualLength);
} finally {
recordingPhaser.readerUnlock();
}
}
/**
* Increment a value at a given index in the array
* @param index the index of the value to be incremented
* @throws ArrayIndexOutOfBoundsException (may throw) if value is exceeds length()
*/
public void increment(final int index) throws ArrayIndexOutOfBoundsException {
long criticalValueAtEnter = recordingPhaser.writerCriticalSectionEnter();
try {
activeArray.increment(index);
} finally {
recordingPhaser.writerCriticalSectionExit(criticalValueAtEnter);
}
}
/**
* Add to a value at a given index in the array
* @param index The index of value to add to
* @param valueToAdd The amount to add to the value at the given index
* @throws ArrayIndexOutOfBoundsException (may throw) if value is exceeds length()
*/
public void add(final int index, final long valueToAdd) throws ArrayIndexOutOfBoundsException {
long criticalValueAtEnter = recordingPhaser.writerCriticalSectionEnter();
try {
activeArray.add(index, valueToAdd);
} finally {
recordingPhaser.writerCriticalSectionExit(criticalValueAtEnter);
}
}
/**
* Get an interval array, which will include a stable, consistent view of all values
* accumulated since the last interval array was taken.
* <p>
* Calling this method is equivalent to calling {@code getIntervalArray(null)}. It is generally recommended
* that the {@link PackedArraySingleWriterRecorder#getIntervalArray(PackedLongArray arrayToRecycle)
* getIntervalHistogram(arrayToRecycle)} orm be used for
* regular interval array sampling, as that form accepts a previously returned interval array that can be
* recycled internally to avoid allocation and content copying operations, and is therefore significantly
* more efficient for repeated use than {@link PackedArraySingleWriterRecorder#getIntervalArray()}.
* <p>
* Calling {@link PackedArraySingleWriterRecorder#getIntervalArray()} will reset the values at
* all indexes of the array tracked by the recorder, and start accumulating values for the next interval.
*
* @return an array containing the values accumulated since the last interval array was taken.
*/
public synchronized PackedLongArray getIntervalArray() {
return getIntervalArray(null);
}
/**
* Get an interval array, which will include a stable, consistent view of all values
* accumulated since the last interval array was taken.
* <p>
* {@link PackedArraySingleWriterRecorder#getIntervalArray(PackedLongArray arrayToRecycle)
* getIntervalArray(arrayToRecycle)}
* accepts a previously returned interval array that can be recycled internally to avoid allocation
* and content copying operations, and is therefore significantly more efficient for repeated use than
* {@link PackedArraySingleWriterRecorder#getIntervalArray()}. The provided {@code arrayToRecycle} must
* be either be null or an interval array returned by a previous call to
* {@link PackedArraySingleWriterRecorder#getIntervalArray(PackedLongArray arrayToRecycle)
* getIntervalArray(arrayToRecycle)} or
* {@link PackedArraySingleWriterRecorder#getIntervalArray()}.
* <p>
* NOTE: The caller is responsible for not recycling the same returned interval array more than once. If
* the same interval array instance is recycled more than once, behavior is undefined.
* <p>
* Calling {@link PackedArraySingleWriterRecorder#getIntervalArray(PackedLongArray arrayToRecycle)
* getIntervalArray(arrayToRecycle)} will reset the values at all indexes of the array
* tracked by the recorder, and start accumulating values for the next interval.
*
* @param arrayToRecycle a previously returned interval array (from this instance of
* {@link PackedArraySingleWriterRecorder}) that may be recycled to avoid allocation and
* copy operations.
* @return an array containing the values accumulated since the last interval array was taken.
*/
public synchronized PackedLongArray getIntervalArray(final PackedLongArray arrayToRecycle) {
return getIntervalArray(arrayToRecycle, true);
}
/**
* Get an interval array, which will include a stable, consistent view of all values
* accumulated since the last interval array was taken.
* <p>
* {@link PackedArraySingleWriterRecorder#getIntervalArray(PackedLongArray arrayToRecycle)
* getIntervalArray(arrayToRecycle)}
* accepts a previously returned interval array that can be recycled internally to avoid allocation
* and content copying operations, and is therefore significantly more efficient for repeated use than
* {@link PackedArraySingleWriterRecorder#getIntervalArray()}. The provided {@code arrayToRecycle} must
* be either be null or an interval array returned by a previous call to
* {@link PackedArraySingleWriterRecorder#getIntervalArray(PackedLongArray arrayToRecycle)
* getIntervalArray(arrayToRecycle)} or
* {@link PackedArraySingleWriterRecorder#getIntervalArray()}.
* <p>
* NOTE: The caller is responsible for not recycling the same returned interval array more than once. If
* the same interval array instance is recycled more than once, behavior is undefined.
* <p>
* Calling {@link PackedArraySingleWriterRecorder#getIntervalArray(PackedLongArray arrayToRecycle)
* getIntervalArray(arrayToRecycle, enforeContainingInstance)} will reset the values at all indexes
* of the array tracked by the recorder, and start accumulating values for the next interval.
*
* @param arrayToRecycle a previously returned interval array that may be recycled to avoid allocation and
* copy operations.
* @param enforceContainingInstance if true, will only allow recycling of arrays previously returned from this
* instance of {@link PackedArraySingleWriterRecorder}. If false, will allow recycling arrays
* previously returned by other instances of {@link PackedArraySingleWriterRecorder}.
* @return an array containing the values accumulated since the last interval array was taken.
*/
public synchronized PackedLongArray getIntervalArray(final PackedLongArray arrayToRecycle,
final boolean enforceContainingInstance) {
// Verify that replacement array can validly be used as an inactive array replacement:
validateFitAsReplacementArray(arrayToRecycle, enforceContainingInstance);
PackedLongArray sampledArray = performIntervalSample(arrayToRecycle);
return sampledArray;
}
/**
* Reset the array contents to all zeros.
*/
public synchronized void reset() {
// the currently active array is reset each time we flip:
performIntervalSample(null);
}
private PackedLongArray performIntervalSample(final PackedLongArray arrayToRecycle) {<FILL_FUNCTION_BODY>}
private static class InternalPackedLongArray extends PackedLongArray {
private final long containingInstanceId;
private InternalPackedLongArray(final long id, int virtualLength, final int initialPhysicalLength) {
super(virtualLength, initialPhysicalLength);
this.containingInstanceId = id;
}
private InternalPackedLongArray(final long id, final int virtualLength) {
super(virtualLength);
this.containingInstanceId = id;
}
}
private void validateFitAsReplacementArray(final PackedLongArray replacementArray,
final boolean enforceContainingInstance) {
boolean bad = true;
if (replacementArray == null) {
bad = false;
} else if (replacementArray instanceof InternalPackedLongArray) {
if ((activeArray instanceof InternalPackedLongArray)
&&
((!enforceContainingInstance) ||
(((InternalPackedLongArray)replacementArray).containingInstanceId ==
((InternalPackedLongArray) activeArray).containingInstanceId)
)) {
bad = false;
}
}
if (bad) {
throw new IllegalArgumentException("replacement array must have been obtained via a previous" +
" getIntervalArray() call from this " + this.getClass().getName() +
(enforceContainingInstance ? " instance" : " class"));
}
}
} |
PackedLongArray inactiveArray = arrayToRecycle;
try {
recordingPhaser.readerLock();
// Make sure we have an inactive version to flip in:
if (inactiveArray == null) {
if (activeArray instanceof InternalPackedLongArray) {
inactiveArray = new InternalPackedLongArray(instanceId, activeArray.length());
} else {
throw new IllegalStateException("Unexpected internal array type for activeArray");
}
} else {
inactiveArray.clear();
}
// Swap active and inactive arrays:
final PackedLongArray tempArray = inactiveArray;
inactiveArray = activeArray;
activeArray = tempArray;
// Mark end time of previous interval and start time of new one:
long now = System.currentTimeMillis();
activeArray.setStartTimeStamp(now);
inactiveArray.setEndTimeStamp(now);
// Make sure we are not in the middle of recording a value on the previously active array:
// Flip phase to make sure no recordings that were in flight pre-flip are still active:
recordingPhaser.flipPhase(500000L /* yield in 0.5 msec units if needed */);
} finally {
recordingPhaser.readerUnlock();
}
return inactiveArray;
|
HdrHistogram_HdrHistogram | HdrHistogram/src/main/java/org/HdrHistogram/packedarray/PackedArraySingleWriterRecorder.java | InternalPackedLongArray | validateFitAsReplacementArray | class InternalPackedLongArray extends PackedLongArray {
private final long containingInstanceId;
private InternalPackedLongArray(final long id, int virtualLength, final int initialPhysicalLength) {
super(virtualLength, initialPhysicalLength);
this.containingInstanceId = id;
}
private InternalPackedLongArray(final long id, final int virtualLength) {
super(virtualLength);
this.containingInstanceId = id;
}
}
private void validateFitAsReplacementArray(final PackedLongArray replacementArray,
final boolean enforceContainingInstance) {<FILL_FUNCTION_BODY> |
boolean bad = true;
if (replacementArray == null) {
bad = false;
} else if (replacementArray instanceof InternalPackedLongArray) {
if ((activeArray instanceof InternalPackedLongArray)
&&
((!enforceContainingInstance) ||
(((InternalPackedLongArray)replacementArray).containingInstanceId ==
((InternalPackedLongArray) activeArray).containingInstanceId)
)) {
bad = false;
}
}
if (bad) {
throw new IllegalArgumentException("replacement array must have been obtained via a previous" +
" getIntervalArray() call from this " + this.getClass().getName() +
(enforceContainingInstance ? " instance" : " class"));
}
|
HotswapProjects_HotswapAgent | HotswapAgent/hotswap-agent-core/src/main/java/org/hotswap/agent/javassist/CtMember.java | Cache | extendToString | class Cache extends CtMember {
@Override
protected void extendToString(StringBuffer buffer) {<FILL_FUNCTION_BODY>}
@Override
public boolean hasAnnotation(String clz) { return false; }
@Override
public Object getAnnotation(Class<?> clz)
throws ClassNotFoundException { return null; }
@Override
public Object[] getAnnotations()
throws ClassNotFoundException { return null; }
@Override
public byte[] getAttribute(String name) { return null; }
@Override
public Object[] getAvailableAnnotations() { return null; }
@Override
public int getModifiers() { return 0; }
@Override
public String getName() { return null; }
@Override
public String getSignature() { return null; }
@Override
public void setAttribute(String name, byte[] data) {}
@Override
public void setModifiers(int mod) {}
@Override
public String getGenericSignature() { return null; }
@Override
public void setGenericSignature(String sig) {}
private CtMember methodTail;
private CtMember consTail; // constructor tail
private CtMember fieldTail;
Cache(CtClassType decl) {
super(decl);
methodTail = this;
consTail = this;
fieldTail = this;
fieldTail.next = this;
}
CtMember methodHead() { return this; }
CtMember lastMethod() { return methodTail; }
CtMember consHead() { return methodTail; } // may include a static initializer
CtMember lastCons() { return consTail; }
CtMember fieldHead() { return consTail; }
CtMember lastField() { return fieldTail; }
void addMethod(CtMember method) {
method.next = methodTail.next;
methodTail.next = method;
if (methodTail == consTail) {
consTail = method;
if (methodTail == fieldTail)
fieldTail = method;
}
methodTail = method;
}
/* Both constructors and a class initializer.
*/
void addConstructor(CtMember cons) {
cons.next = consTail.next;
consTail.next = cons;
if (consTail == fieldTail)
fieldTail = cons;
consTail = cons;
}
void addField(CtMember field) {
field.next = this; // or fieldTail.next
fieldTail.next = field;
fieldTail = field;
}
static int count(CtMember head, CtMember tail) {
int n = 0;
while (head != tail) {
n++;
head = head.next;
}
return n;
}
void remove(CtMember mem) {
CtMember m = this;
CtMember node;
while ((node = m.next) != this) {
if (node == mem) {
m.next = node.next;
if (node == methodTail)
methodTail = m;
if (node == consTail)
consTail = m;
if (node == fieldTail)
fieldTail = m;
break;
}
m = m.next;
}
}
} | |
HotswapProjects_HotswapAgent | HotswapAgent/hotswap-agent-core/src/main/java/org/hotswap/agent/javassist/CtMember.java | Cache | hasAnnotation | class Cache extends CtMember {
@Override
protected void extendToString(StringBuffer buffer) {}
@Override
public boolean hasAnnotation(String clz) {<FILL_FUNCTION_BODY>}
@Override
public Object getAnnotation(Class<?> clz)
throws ClassNotFoundException { return null; }
@Override
public Object[] getAnnotations()
throws ClassNotFoundException { return null; }
@Override
public byte[] getAttribute(String name) { return null; }
@Override
public Object[] getAvailableAnnotations() { return null; }
@Override
public int getModifiers() { return 0; }
@Override
public String getName() { return null; }
@Override
public String getSignature() { return null; }
@Override
public void setAttribute(String name, byte[] data) {}
@Override
public void setModifiers(int mod) {}
@Override
public String getGenericSignature() { return null; }
@Override
public void setGenericSignature(String sig) {}
private CtMember methodTail;
private CtMember consTail; // constructor tail
private CtMember fieldTail;
Cache(CtClassType decl) {
super(decl);
methodTail = this;
consTail = this;
fieldTail = this;
fieldTail.next = this;
}
CtMember methodHead() { return this; }
CtMember lastMethod() { return methodTail; }
CtMember consHead() { return methodTail; } // may include a static initializer
CtMember lastCons() { return consTail; }
CtMember fieldHead() { return consTail; }
CtMember lastField() { return fieldTail; }
void addMethod(CtMember method) {
method.next = methodTail.next;
methodTail.next = method;
if (methodTail == consTail) {
consTail = method;
if (methodTail == fieldTail)
fieldTail = method;
}
methodTail = method;
}
/* Both constructors and a class initializer.
*/
void addConstructor(CtMember cons) {
cons.next = consTail.next;
consTail.next = cons;
if (consTail == fieldTail)
fieldTail = cons;
consTail = cons;
}
void addField(CtMember field) {
field.next = this; // or fieldTail.next
fieldTail.next = field;
fieldTail = field;
}
static int count(CtMember head, CtMember tail) {
int n = 0;
while (head != tail) {
n++;
head = head.next;
}
return n;
}
void remove(CtMember mem) {
CtMember m = this;
CtMember node;
while ((node = m.next) != this) {
if (node == mem) {
m.next = node.next;
if (node == methodTail)
methodTail = m;
if (node == consTail)
consTail = m;
if (node == fieldTail)
fieldTail = m;
break;
}
m = m.next;
}
}
} | return false; |
HotswapProjects_HotswapAgent | HotswapAgent/hotswap-agent-core/src/main/java/org/hotswap/agent/javassist/CtMember.java | Cache | getAnnotation | class Cache extends CtMember {
@Override
protected void extendToString(StringBuffer buffer) {}
@Override
public boolean hasAnnotation(String clz) { return false; }
@Override
public Object getAnnotation(Class<?> clz)
throws ClassNotFoundException {<FILL_FUNCTION_BODY>}
@Override
public Object[] getAnnotations()
throws ClassNotFoundException { return null; }
@Override
public byte[] getAttribute(String name) { return null; }
@Override
public Object[] getAvailableAnnotations() { return null; }
@Override
public int getModifiers() { return 0; }
@Override
public String getName() { return null; }
@Override
public String getSignature() { return null; }
@Override
public void setAttribute(String name, byte[] data) {}
@Override
public void setModifiers(int mod) {}
@Override
public String getGenericSignature() { return null; }
@Override
public void setGenericSignature(String sig) {}
private CtMember methodTail;
private CtMember consTail; // constructor tail
private CtMember fieldTail;
Cache(CtClassType decl) {
super(decl);
methodTail = this;
consTail = this;
fieldTail = this;
fieldTail.next = this;
}
CtMember methodHead() { return this; }
CtMember lastMethod() { return methodTail; }
CtMember consHead() { return methodTail; } // may include a static initializer
CtMember lastCons() { return consTail; }
CtMember fieldHead() { return consTail; }
CtMember lastField() { return fieldTail; }
void addMethod(CtMember method) {
method.next = methodTail.next;
methodTail.next = method;
if (methodTail == consTail) {
consTail = method;
if (methodTail == fieldTail)
fieldTail = method;
}
methodTail = method;
}
/* Both constructors and a class initializer.
*/
void addConstructor(CtMember cons) {
cons.next = consTail.next;
consTail.next = cons;
if (consTail == fieldTail)
fieldTail = cons;
consTail = cons;
}
void addField(CtMember field) {
field.next = this; // or fieldTail.next
fieldTail.next = field;
fieldTail = field;
}
static int count(CtMember head, CtMember tail) {
int n = 0;
while (head != tail) {
n++;
head = head.next;
}
return n;
}
void remove(CtMember mem) {
CtMember m = this;
CtMember node;
while ((node = m.next) != this) {
if (node == mem) {
m.next = node.next;
if (node == methodTail)
methodTail = m;
if (node == consTail)
consTail = m;
if (node == fieldTail)
fieldTail = m;
break;
}
m = m.next;
}
}
} | return null; |
HotswapProjects_HotswapAgent | HotswapAgent/hotswap-agent-core/src/main/java/org/hotswap/agent/javassist/CtMember.java | Cache | getAnnotations | class Cache extends CtMember {
@Override
protected void extendToString(StringBuffer buffer) {}
@Override
public boolean hasAnnotation(String clz) { return false; }
@Override
public Object getAnnotation(Class<?> clz)
throws ClassNotFoundException { return null; }
@Override
public Object[] getAnnotations()
throws ClassNotFoundException {<FILL_FUNCTION_BODY>}
@Override
public byte[] getAttribute(String name) { return null; }
@Override
public Object[] getAvailableAnnotations() { return null; }
@Override
public int getModifiers() { return 0; }
@Override
public String getName() { return null; }
@Override
public String getSignature() { return null; }
@Override
public void setAttribute(String name, byte[] data) {}
@Override
public void setModifiers(int mod) {}
@Override
public String getGenericSignature() { return null; }
@Override
public void setGenericSignature(String sig) {}
private CtMember methodTail;
private CtMember consTail; // constructor tail
private CtMember fieldTail;
Cache(CtClassType decl) {
super(decl);
methodTail = this;
consTail = this;
fieldTail = this;
fieldTail.next = this;
}
CtMember methodHead() { return this; }
CtMember lastMethod() { return methodTail; }
CtMember consHead() { return methodTail; } // may include a static initializer
CtMember lastCons() { return consTail; }
CtMember fieldHead() { return consTail; }
CtMember lastField() { return fieldTail; }
void addMethod(CtMember method) {
method.next = methodTail.next;
methodTail.next = method;
if (methodTail == consTail) {
consTail = method;
if (methodTail == fieldTail)
fieldTail = method;
}
methodTail = method;
}
/* Both constructors and a class initializer.
*/
void addConstructor(CtMember cons) {
cons.next = consTail.next;
consTail.next = cons;
if (consTail == fieldTail)
fieldTail = cons;
consTail = cons;
}
void addField(CtMember field) {
field.next = this; // or fieldTail.next
fieldTail.next = field;
fieldTail = field;
}
static int count(CtMember head, CtMember tail) {
int n = 0;
while (head != tail) {
n++;
head = head.next;
}
return n;
}
void remove(CtMember mem) {
CtMember m = this;
CtMember node;
while ((node = m.next) != this) {
if (node == mem) {
m.next = node.next;
if (node == methodTail)
methodTail = m;
if (node == consTail)
consTail = m;
if (node == fieldTail)
fieldTail = m;
break;
}
m = m.next;
}
}
} | return null; |
HotswapProjects_HotswapAgent | HotswapAgent/hotswap-agent-core/src/main/java/org/hotswap/agent/javassist/CtMember.java | Cache | getAttribute | class Cache extends CtMember {
@Override
protected void extendToString(StringBuffer buffer) {}
@Override
public boolean hasAnnotation(String clz) { return false; }
@Override
public Object getAnnotation(Class<?> clz)
throws ClassNotFoundException { return null; }
@Override
public Object[] getAnnotations()
throws ClassNotFoundException { return null; }
@Override
public byte[] getAttribute(String name) {<FILL_FUNCTION_BODY>}
@Override
public Object[] getAvailableAnnotations() { return null; }
@Override
public int getModifiers() { return 0; }
@Override
public String getName() { return null; }
@Override
public String getSignature() { return null; }
@Override
public void setAttribute(String name, byte[] data) {}
@Override
public void setModifiers(int mod) {}
@Override
public String getGenericSignature() { return null; }
@Override
public void setGenericSignature(String sig) {}
private CtMember methodTail;
private CtMember consTail; // constructor tail
private CtMember fieldTail;
Cache(CtClassType decl) {
super(decl);
methodTail = this;
consTail = this;
fieldTail = this;
fieldTail.next = this;
}
CtMember methodHead() { return this; }
CtMember lastMethod() { return methodTail; }
CtMember consHead() { return methodTail; } // may include a static initializer
CtMember lastCons() { return consTail; }
CtMember fieldHead() { return consTail; }
CtMember lastField() { return fieldTail; }
void addMethod(CtMember method) {
method.next = methodTail.next;
methodTail.next = method;
if (methodTail == consTail) {
consTail = method;
if (methodTail == fieldTail)
fieldTail = method;
}
methodTail = method;
}
/* Both constructors and a class initializer.
*/
void addConstructor(CtMember cons) {
cons.next = consTail.next;
consTail.next = cons;
if (consTail == fieldTail)
fieldTail = cons;
consTail = cons;
}
void addField(CtMember field) {
field.next = this; // or fieldTail.next
fieldTail.next = field;
fieldTail = field;
}
static int count(CtMember head, CtMember tail) {
int n = 0;
while (head != tail) {
n++;
head = head.next;
}
return n;
}
void remove(CtMember mem) {
CtMember m = this;
CtMember node;
while ((node = m.next) != this) {
if (node == mem) {
m.next = node.next;
if (node == methodTail)
methodTail = m;
if (node == consTail)
consTail = m;
if (node == fieldTail)
fieldTail = m;
break;
}
m = m.next;
}
}
} | return null; |
HotswapProjects_HotswapAgent | HotswapAgent/hotswap-agent-core/src/main/java/org/hotswap/agent/javassist/CtMember.java | Cache | getAvailableAnnotations | class Cache extends CtMember {
@Override
protected void extendToString(StringBuffer buffer) {}
@Override
public boolean hasAnnotation(String clz) { return false; }
@Override
public Object getAnnotation(Class<?> clz)
throws ClassNotFoundException { return null; }
@Override
public Object[] getAnnotations()
throws ClassNotFoundException { return null; }
@Override
public byte[] getAttribute(String name) { return null; }
@Override
public Object[] getAvailableAnnotations() {<FILL_FUNCTION_BODY>}
@Override
public int getModifiers() { return 0; }
@Override
public String getName() { return null; }
@Override
public String getSignature() { return null; }
@Override
public void setAttribute(String name, byte[] data) {}
@Override
public void setModifiers(int mod) {}
@Override
public String getGenericSignature() { return null; }
@Override
public void setGenericSignature(String sig) {}
private CtMember methodTail;
private CtMember consTail; // constructor tail
private CtMember fieldTail;
Cache(CtClassType decl) {
super(decl);
methodTail = this;
consTail = this;
fieldTail = this;
fieldTail.next = this;
}
CtMember methodHead() { return this; }
CtMember lastMethod() { return methodTail; }
CtMember consHead() { return methodTail; } // may include a static initializer
CtMember lastCons() { return consTail; }
CtMember fieldHead() { return consTail; }
CtMember lastField() { return fieldTail; }
void addMethod(CtMember method) {
method.next = methodTail.next;
methodTail.next = method;
if (methodTail == consTail) {
consTail = method;
if (methodTail == fieldTail)
fieldTail = method;
}
methodTail = method;
}
/* Both constructors and a class initializer.
*/
void addConstructor(CtMember cons) {
cons.next = consTail.next;
consTail.next = cons;
if (consTail == fieldTail)
fieldTail = cons;
consTail = cons;
}
void addField(CtMember field) {
field.next = this; // or fieldTail.next
fieldTail.next = field;
fieldTail = field;
}
static int count(CtMember head, CtMember tail) {
int n = 0;
while (head != tail) {
n++;
head = head.next;
}
return n;
}
void remove(CtMember mem) {
CtMember m = this;
CtMember node;
while ((node = m.next) != this) {
if (node == mem) {
m.next = node.next;
if (node == methodTail)
methodTail = m;
if (node == consTail)
consTail = m;
if (node == fieldTail)
fieldTail = m;
break;
}
m = m.next;
}
}
} | return null; |
HotswapProjects_HotswapAgent | HotswapAgent/hotswap-agent-core/src/main/java/org/hotswap/agent/javassist/CtMember.java | Cache | getModifiers | class Cache extends CtMember {
@Override
protected void extendToString(StringBuffer buffer) {}
@Override
public boolean hasAnnotation(String clz) { return false; }
@Override
public Object getAnnotation(Class<?> clz)
throws ClassNotFoundException { return null; }
@Override
public Object[] getAnnotations()
throws ClassNotFoundException { return null; }
@Override
public byte[] getAttribute(String name) { return null; }
@Override
public Object[] getAvailableAnnotations() { return null; }
@Override
public int getModifiers() {<FILL_FUNCTION_BODY>}
@Override
public String getName() { return null; }
@Override
public String getSignature() { return null; }
@Override
public void setAttribute(String name, byte[] data) {}
@Override
public void setModifiers(int mod) {}
@Override
public String getGenericSignature() { return null; }
@Override
public void setGenericSignature(String sig) {}
private CtMember methodTail;
private CtMember consTail; // constructor tail
private CtMember fieldTail;
Cache(CtClassType decl) {
super(decl);
methodTail = this;
consTail = this;
fieldTail = this;
fieldTail.next = this;
}
CtMember methodHead() { return this; }
CtMember lastMethod() { return methodTail; }
CtMember consHead() { return methodTail; } // may include a static initializer
CtMember lastCons() { return consTail; }
CtMember fieldHead() { return consTail; }
CtMember lastField() { return fieldTail; }
void addMethod(CtMember method) {
method.next = methodTail.next;
methodTail.next = method;
if (methodTail == consTail) {
consTail = method;
if (methodTail == fieldTail)
fieldTail = method;
}
methodTail = method;
}
/* Both constructors and a class initializer.
*/
void addConstructor(CtMember cons) {
cons.next = consTail.next;
consTail.next = cons;
if (consTail == fieldTail)
fieldTail = cons;
consTail = cons;
}
void addField(CtMember field) {
field.next = this; // or fieldTail.next
fieldTail.next = field;
fieldTail = field;
}
static int count(CtMember head, CtMember tail) {
int n = 0;
while (head != tail) {
n++;
head = head.next;
}
return n;
}
void remove(CtMember mem) {
CtMember m = this;
CtMember node;
while ((node = m.next) != this) {
if (node == mem) {
m.next = node.next;
if (node == methodTail)
methodTail = m;
if (node == consTail)
consTail = m;
if (node == fieldTail)
fieldTail = m;
break;
}
m = m.next;
}
}
} | return 0; |
HotswapProjects_HotswapAgent | HotswapAgent/hotswap-agent-core/src/main/java/org/hotswap/agent/javassist/CtMember.java | Cache | getName | class Cache extends CtMember {
@Override
protected void extendToString(StringBuffer buffer) {}
@Override
public boolean hasAnnotation(String clz) { return false; }
@Override
public Object getAnnotation(Class<?> clz)
throws ClassNotFoundException { return null; }
@Override
public Object[] getAnnotations()
throws ClassNotFoundException { return null; }
@Override
public byte[] getAttribute(String name) { return null; }
@Override
public Object[] getAvailableAnnotations() { return null; }
@Override
public int getModifiers() { return 0; }
@Override
public String getName() {<FILL_FUNCTION_BODY>}
@Override
public String getSignature() { return null; }
@Override
public void setAttribute(String name, byte[] data) {}
@Override
public void setModifiers(int mod) {}
@Override
public String getGenericSignature() { return null; }
@Override
public void setGenericSignature(String sig) {}
private CtMember methodTail;
private CtMember consTail; // constructor tail
private CtMember fieldTail;
Cache(CtClassType decl) {
super(decl);
methodTail = this;
consTail = this;
fieldTail = this;
fieldTail.next = this;
}
CtMember methodHead() { return this; }
CtMember lastMethod() { return methodTail; }
CtMember consHead() { return methodTail; } // may include a static initializer
CtMember lastCons() { return consTail; }
CtMember fieldHead() { return consTail; }
CtMember lastField() { return fieldTail; }
void addMethod(CtMember method) {
method.next = methodTail.next;
methodTail.next = method;
if (methodTail == consTail) {
consTail = method;
if (methodTail == fieldTail)
fieldTail = method;
}
methodTail = method;
}
/* Both constructors and a class initializer.
*/
void addConstructor(CtMember cons) {
cons.next = consTail.next;
consTail.next = cons;
if (consTail == fieldTail)
fieldTail = cons;
consTail = cons;
}
void addField(CtMember field) {
field.next = this; // or fieldTail.next
fieldTail.next = field;
fieldTail = field;
}
static int count(CtMember head, CtMember tail) {
int n = 0;
while (head != tail) {
n++;
head = head.next;
}
return n;
}
void remove(CtMember mem) {
CtMember m = this;
CtMember node;
while ((node = m.next) != this) {
if (node == mem) {
m.next = node.next;
if (node == methodTail)
methodTail = m;
if (node == consTail)
consTail = m;
if (node == fieldTail)
fieldTail = m;
break;
}
m = m.next;
}
}
} | return null; |
HotswapProjects_HotswapAgent | HotswapAgent/hotswap-agent-core/src/main/java/org/hotswap/agent/javassist/CtMember.java | Cache | getSignature | class Cache extends CtMember {
@Override
protected void extendToString(StringBuffer buffer) {}
@Override
public boolean hasAnnotation(String clz) { return false; }
@Override
public Object getAnnotation(Class<?> clz)
throws ClassNotFoundException { return null; }
@Override
public Object[] getAnnotations()
throws ClassNotFoundException { return null; }
@Override
public byte[] getAttribute(String name) { return null; }
@Override
public Object[] getAvailableAnnotations() { return null; }
@Override
public int getModifiers() { return 0; }
@Override
public String getName() { return null; }
@Override
public String getSignature() {<FILL_FUNCTION_BODY>}
@Override
public void setAttribute(String name, byte[] data) {}
@Override
public void setModifiers(int mod) {}
@Override
public String getGenericSignature() { return null; }
@Override
public void setGenericSignature(String sig) {}
private CtMember methodTail;
private CtMember consTail; // constructor tail
private CtMember fieldTail;
Cache(CtClassType decl) {
super(decl);
methodTail = this;
consTail = this;
fieldTail = this;
fieldTail.next = this;
}
CtMember methodHead() { return this; }
CtMember lastMethod() { return methodTail; }
CtMember consHead() { return methodTail; } // may include a static initializer
CtMember lastCons() { return consTail; }
CtMember fieldHead() { return consTail; }
CtMember lastField() { return fieldTail; }
void addMethod(CtMember method) {
method.next = methodTail.next;
methodTail.next = method;
if (methodTail == consTail) {
consTail = method;
if (methodTail == fieldTail)
fieldTail = method;
}
methodTail = method;
}
/* Both constructors and a class initializer.
*/
void addConstructor(CtMember cons) {
cons.next = consTail.next;
consTail.next = cons;
if (consTail == fieldTail)
fieldTail = cons;
consTail = cons;
}
void addField(CtMember field) {
field.next = this; // or fieldTail.next
fieldTail.next = field;
fieldTail = field;
}
static int count(CtMember head, CtMember tail) {
int n = 0;
while (head != tail) {
n++;
head = head.next;
}
return n;
}
void remove(CtMember mem) {
CtMember m = this;
CtMember node;
while ((node = m.next) != this) {
if (node == mem) {
m.next = node.next;
if (node == methodTail)
methodTail = m;
if (node == consTail)
consTail = m;
if (node == fieldTail)
fieldTail = m;
break;
}
m = m.next;
}
}
} | return null; |
HotswapProjects_HotswapAgent | HotswapAgent/hotswap-agent-core/src/main/java/org/hotswap/agent/javassist/CtMember.java | Cache | setAttribute | class Cache extends CtMember {
@Override
protected void extendToString(StringBuffer buffer) {}
@Override
public boolean hasAnnotation(String clz) { return false; }
@Override
public Object getAnnotation(Class<?> clz)
throws ClassNotFoundException { return null; }
@Override
public Object[] getAnnotations()
throws ClassNotFoundException { return null; }
@Override
public byte[] getAttribute(String name) { return null; }
@Override
public Object[] getAvailableAnnotations() { return null; }
@Override
public int getModifiers() { return 0; }
@Override
public String getName() { return null; }
@Override
public String getSignature() { return null; }
@Override
public void setAttribute(String name, byte[] data) {<FILL_FUNCTION_BODY>}
@Override
public void setModifiers(int mod) {}
@Override
public String getGenericSignature() { return null; }
@Override
public void setGenericSignature(String sig) {}
private CtMember methodTail;
private CtMember consTail; // constructor tail
private CtMember fieldTail;
Cache(CtClassType decl) {
super(decl);
methodTail = this;
consTail = this;
fieldTail = this;
fieldTail.next = this;
}
CtMember methodHead() { return this; }
CtMember lastMethod() { return methodTail; }
CtMember consHead() { return methodTail; } // may include a static initializer
CtMember lastCons() { return consTail; }
CtMember fieldHead() { return consTail; }
CtMember lastField() { return fieldTail; }
void addMethod(CtMember method) {
method.next = methodTail.next;
methodTail.next = method;
if (methodTail == consTail) {
consTail = method;
if (methodTail == fieldTail)
fieldTail = method;
}
methodTail = method;
}
/* Both constructors and a class initializer.
*/
void addConstructor(CtMember cons) {
cons.next = consTail.next;
consTail.next = cons;
if (consTail == fieldTail)
fieldTail = cons;
consTail = cons;
}
void addField(CtMember field) {
field.next = this; // or fieldTail.next
fieldTail.next = field;
fieldTail = field;
}
static int count(CtMember head, CtMember tail) {
int n = 0;
while (head != tail) {
n++;
head = head.next;
}
return n;
}
void remove(CtMember mem) {
CtMember m = this;
CtMember node;
while ((node = m.next) != this) {
if (node == mem) {
m.next = node.next;
if (node == methodTail)
methodTail = m;
if (node == consTail)
consTail = m;
if (node == fieldTail)
fieldTail = m;
break;
}
m = m.next;
}
}
} | |
HotswapProjects_HotswapAgent | HotswapAgent/hotswap-agent-core/src/main/java/org/hotswap/agent/javassist/CtMember.java | Cache | setModifiers | class Cache extends CtMember {
@Override
protected void extendToString(StringBuffer buffer) {}
@Override
public boolean hasAnnotation(String clz) { return false; }
@Override
public Object getAnnotation(Class<?> clz)
throws ClassNotFoundException { return null; }
@Override
public Object[] getAnnotations()
throws ClassNotFoundException { return null; }
@Override
public byte[] getAttribute(String name) { return null; }
@Override
public Object[] getAvailableAnnotations() { return null; }
@Override
public int getModifiers() { return 0; }
@Override
public String getName() { return null; }
@Override
public String getSignature() { return null; }
@Override
public void setAttribute(String name, byte[] data) {}
@Override
public void setModifiers(int mod) {<FILL_FUNCTION_BODY>}
@Override
public String getGenericSignature() { return null; }
@Override
public void setGenericSignature(String sig) {}
private CtMember methodTail;
private CtMember consTail; // constructor tail
private CtMember fieldTail;
Cache(CtClassType decl) {
super(decl);
methodTail = this;
consTail = this;
fieldTail = this;
fieldTail.next = this;
}
CtMember methodHead() { return this; }
CtMember lastMethod() { return methodTail; }
CtMember consHead() { return methodTail; } // may include a static initializer
CtMember lastCons() { return consTail; }
CtMember fieldHead() { return consTail; }
CtMember lastField() { return fieldTail; }
void addMethod(CtMember method) {
method.next = methodTail.next;
methodTail.next = method;
if (methodTail == consTail) {
consTail = method;
if (methodTail == fieldTail)
fieldTail = method;
}
methodTail = method;
}
/* Both constructors and a class initializer.
*/
void addConstructor(CtMember cons) {
cons.next = consTail.next;
consTail.next = cons;
if (consTail == fieldTail)
fieldTail = cons;
consTail = cons;
}
void addField(CtMember field) {
field.next = this; // or fieldTail.next
fieldTail.next = field;
fieldTail = field;
}
static int count(CtMember head, CtMember tail) {
int n = 0;
while (head != tail) {
n++;
head = head.next;
}
return n;
}
void remove(CtMember mem) {
CtMember m = this;
CtMember node;
while ((node = m.next) != this) {
if (node == mem) {
m.next = node.next;
if (node == methodTail)
methodTail = m;
if (node == consTail)
consTail = m;
if (node == fieldTail)
fieldTail = m;
break;
}
m = m.next;
}
}
} | |
HotswapProjects_HotswapAgent | HotswapAgent/hotswap-agent-core/src/main/java/org/hotswap/agent/javassist/CtMember.java | Cache | getGenericSignature | class Cache extends CtMember {
@Override
protected void extendToString(StringBuffer buffer) {}
@Override
public boolean hasAnnotation(String clz) { return false; }
@Override
public Object getAnnotation(Class<?> clz)
throws ClassNotFoundException { return null; }
@Override
public Object[] getAnnotations()
throws ClassNotFoundException { return null; }
@Override
public byte[] getAttribute(String name) { return null; }
@Override
public Object[] getAvailableAnnotations() { return null; }
@Override
public int getModifiers() { return 0; }
@Override
public String getName() { return null; }
@Override
public String getSignature() { return null; }
@Override
public void setAttribute(String name, byte[] data) {}
@Override
public void setModifiers(int mod) {}
@Override
public String getGenericSignature() {<FILL_FUNCTION_BODY>}
@Override
public void setGenericSignature(String sig) {}
private CtMember methodTail;
private CtMember consTail; // constructor tail
private CtMember fieldTail;
Cache(CtClassType decl) {
super(decl);
methodTail = this;
consTail = this;
fieldTail = this;
fieldTail.next = this;
}
CtMember methodHead() { return this; }
CtMember lastMethod() { return methodTail; }
CtMember consHead() { return methodTail; } // may include a static initializer
CtMember lastCons() { return consTail; }
CtMember fieldHead() { return consTail; }
CtMember lastField() { return fieldTail; }
void addMethod(CtMember method) {
method.next = methodTail.next;
methodTail.next = method;
if (methodTail == consTail) {
consTail = method;
if (methodTail == fieldTail)
fieldTail = method;
}
methodTail = method;
}
/* Both constructors and a class initializer.
*/
void addConstructor(CtMember cons) {
cons.next = consTail.next;
consTail.next = cons;
if (consTail == fieldTail)
fieldTail = cons;
consTail = cons;
}
void addField(CtMember field) {
field.next = this; // or fieldTail.next
fieldTail.next = field;
fieldTail = field;
}
static int count(CtMember head, CtMember tail) {
int n = 0;
while (head != tail) {
n++;
head = head.next;
}
return n;
}
void remove(CtMember mem) {
CtMember m = this;
CtMember node;
while ((node = m.next) != this) {
if (node == mem) {
m.next = node.next;
if (node == methodTail)
methodTail = m;
if (node == consTail)
consTail = m;
if (node == fieldTail)
fieldTail = m;
break;
}
m = m.next;
}
}
} | return null; |
HotswapProjects_HotswapAgent | HotswapAgent/hotswap-agent-core/src/main/java/org/hotswap/agent/javassist/CtMember.java | Cache | setGenericSignature | class Cache extends CtMember {
@Override
protected void extendToString(StringBuffer buffer) {}
@Override
public boolean hasAnnotation(String clz) { return false; }
@Override
public Object getAnnotation(Class<?> clz)
throws ClassNotFoundException { return null; }
@Override
public Object[] getAnnotations()
throws ClassNotFoundException { return null; }
@Override
public byte[] getAttribute(String name) { return null; }
@Override
public Object[] getAvailableAnnotations() { return null; }
@Override
public int getModifiers() { return 0; }
@Override
public String getName() { return null; }
@Override
public String getSignature() { return null; }
@Override
public void setAttribute(String name, byte[] data) {}
@Override
public void setModifiers(int mod) {}
@Override
public String getGenericSignature() { return null; }
@Override
public void setGenericSignature(String sig) {<FILL_FUNCTION_BODY>}
private CtMember methodTail;
private CtMember consTail; // constructor tail
private CtMember fieldTail;
Cache(CtClassType decl) {
super(decl);
methodTail = this;
consTail = this;
fieldTail = this;
fieldTail.next = this;
}
CtMember methodHead() { return this; }
CtMember lastMethod() { return methodTail; }
CtMember consHead() { return methodTail; } // may include a static initializer
CtMember lastCons() { return consTail; }
CtMember fieldHead() { return consTail; }
CtMember lastField() { return fieldTail; }
void addMethod(CtMember method) {
method.next = methodTail.next;
methodTail.next = method;
if (methodTail == consTail) {
consTail = method;
if (methodTail == fieldTail)
fieldTail = method;
}
methodTail = method;
}
/* Both constructors and a class initializer.
*/
void addConstructor(CtMember cons) {
cons.next = consTail.next;
consTail.next = cons;
if (consTail == fieldTail)
fieldTail = cons;
consTail = cons;
}
void addField(CtMember field) {
field.next = this; // or fieldTail.next
fieldTail.next = field;
fieldTail = field;
}
static int count(CtMember head, CtMember tail) {
int n = 0;
while (head != tail) {
n++;
head = head.next;
}
return n;
}
void remove(CtMember mem) {
CtMember m = this;
CtMember node;
while ((node = m.next) != this) {
if (node == mem) {
m.next = node.next;
if (node == methodTail)
methodTail = m;
if (node == consTail)
consTail = m;
if (node == fieldTail)
fieldTail = m;
break;
}
m = m.next;
}
}
} | |
HotswapProjects_HotswapAgent | HotswapAgent/hotswap-agent-core/src/main/java/org/hotswap/agent/javassist/CtMember.java | Cache | methodHead | class Cache extends CtMember {
@Override
protected void extendToString(StringBuffer buffer) {}
@Override
public boolean hasAnnotation(String clz) { return false; }
@Override
public Object getAnnotation(Class<?> clz)
throws ClassNotFoundException { return null; }
@Override
public Object[] getAnnotations()
throws ClassNotFoundException { return null; }
@Override
public byte[] getAttribute(String name) { return null; }
@Override
public Object[] getAvailableAnnotations() { return null; }
@Override
public int getModifiers() { return 0; }
@Override
public String getName() { return null; }
@Override
public String getSignature() { return null; }
@Override
public void setAttribute(String name, byte[] data) {}
@Override
public void setModifiers(int mod) {}
@Override
public String getGenericSignature() { return null; }
@Override
public void setGenericSignature(String sig) {}
private CtMember methodTail;
private CtMember consTail; // constructor tail
private CtMember fieldTail;
Cache(CtClassType decl) {
super(decl);
methodTail = this;
consTail = this;
fieldTail = this;
fieldTail.next = this;
}
CtMember methodHead() {<FILL_FUNCTION_BODY>}
CtMember lastMethod() { return methodTail; }
CtMember consHead() { return methodTail; } // may include a static initializer
CtMember lastCons() { return consTail; }
CtMember fieldHead() { return consTail; }
CtMember lastField() { return fieldTail; }
void addMethod(CtMember method) {
method.next = methodTail.next;
methodTail.next = method;
if (methodTail == consTail) {
consTail = method;
if (methodTail == fieldTail)
fieldTail = method;
}
methodTail = method;
}
/* Both constructors and a class initializer.
*/
void addConstructor(CtMember cons) {
cons.next = consTail.next;
consTail.next = cons;
if (consTail == fieldTail)
fieldTail = cons;
consTail = cons;
}
void addField(CtMember field) {
field.next = this; // or fieldTail.next
fieldTail.next = field;
fieldTail = field;
}
static int count(CtMember head, CtMember tail) {
int n = 0;
while (head != tail) {
n++;
head = head.next;
}
return n;
}
void remove(CtMember mem) {
CtMember m = this;
CtMember node;
while ((node = m.next) != this) {
if (node == mem) {
m.next = node.next;
if (node == methodTail)
methodTail = m;
if (node == consTail)
consTail = m;
if (node == fieldTail)
fieldTail = m;
break;
}
m = m.next;
}
}
} | return this; |
HotswapProjects_HotswapAgent | HotswapAgent/hotswap-agent-core/src/main/java/org/hotswap/agent/javassist/CtMember.java | Cache | lastMethod | class Cache extends CtMember {
@Override
protected void extendToString(StringBuffer buffer) {}
@Override
public boolean hasAnnotation(String clz) { return false; }
@Override
public Object getAnnotation(Class<?> clz)
throws ClassNotFoundException { return null; }
@Override
public Object[] getAnnotations()
throws ClassNotFoundException { return null; }
@Override
public byte[] getAttribute(String name) { return null; }
@Override
public Object[] getAvailableAnnotations() { return null; }
@Override
public int getModifiers() { return 0; }
@Override
public String getName() { return null; }
@Override
public String getSignature() { return null; }
@Override
public void setAttribute(String name, byte[] data) {}
@Override
public void setModifiers(int mod) {}
@Override
public String getGenericSignature() { return null; }
@Override
public void setGenericSignature(String sig) {}
private CtMember methodTail;
private CtMember consTail; // constructor tail
private CtMember fieldTail;
Cache(CtClassType decl) {
super(decl);
methodTail = this;
consTail = this;
fieldTail = this;
fieldTail.next = this;
}
CtMember methodHead() { return this; }
CtMember lastMethod() {<FILL_FUNCTION_BODY>}
CtMember consHead() { return methodTail; } // may include a static initializer
CtMember lastCons() { return consTail; }
CtMember fieldHead() { return consTail; }
CtMember lastField() { return fieldTail; }
void addMethod(CtMember method) {
method.next = methodTail.next;
methodTail.next = method;
if (methodTail == consTail) {
consTail = method;
if (methodTail == fieldTail)
fieldTail = method;
}
methodTail = method;
}
/* Both constructors and a class initializer.
*/
void addConstructor(CtMember cons) {
cons.next = consTail.next;
consTail.next = cons;
if (consTail == fieldTail)
fieldTail = cons;
consTail = cons;
}
void addField(CtMember field) {
field.next = this; // or fieldTail.next
fieldTail.next = field;
fieldTail = field;
}
static int count(CtMember head, CtMember tail) {
int n = 0;
while (head != tail) {
n++;
head = head.next;
}
return n;
}
void remove(CtMember mem) {
CtMember m = this;
CtMember node;
while ((node = m.next) != this) {
if (node == mem) {
m.next = node.next;
if (node == methodTail)
methodTail = m;
if (node == consTail)
consTail = m;
if (node == fieldTail)
fieldTail = m;
break;
}
m = m.next;
}
}
} | return methodTail; |
HotswapProjects_HotswapAgent | HotswapAgent/hotswap-agent-core/src/main/java/org/hotswap/agent/javassist/CtMember.java | Cache | consHead | class Cache extends CtMember {
@Override
protected void extendToString(StringBuffer buffer) {}
@Override
public boolean hasAnnotation(String clz) { return false; }
@Override
public Object getAnnotation(Class<?> clz)
throws ClassNotFoundException { return null; }
@Override
public Object[] getAnnotations()
throws ClassNotFoundException { return null; }
@Override
public byte[] getAttribute(String name) { return null; }
@Override
public Object[] getAvailableAnnotations() { return null; }
@Override
public int getModifiers() { return 0; }
@Override
public String getName() { return null; }
@Override
public String getSignature() { return null; }
@Override
public void setAttribute(String name, byte[] data) {}
@Override
public void setModifiers(int mod) {}
@Override
public String getGenericSignature() { return null; }
@Override
public void setGenericSignature(String sig) {}
private CtMember methodTail;
private CtMember consTail; // constructor tail
private CtMember fieldTail;
Cache(CtClassType decl) {
super(decl);
methodTail = this;
consTail = this;
fieldTail = this;
fieldTail.next = this;
}
CtMember methodHead() { return this; }
CtMember lastMethod() { return methodTail; }
CtMember consHead() {<FILL_FUNCTION_BODY>} // may include a static initializer
CtMember lastCons() { return consTail; }
CtMember fieldHead() { return consTail; }
CtMember lastField() { return fieldTail; }
void addMethod(CtMember method) {
method.next = methodTail.next;
methodTail.next = method;
if (methodTail == consTail) {
consTail = method;
if (methodTail == fieldTail)
fieldTail = method;
}
methodTail = method;
}
/* Both constructors and a class initializer.
*/
void addConstructor(CtMember cons) {
cons.next = consTail.next;
consTail.next = cons;
if (consTail == fieldTail)
fieldTail = cons;
consTail = cons;
}
void addField(CtMember field) {
field.next = this; // or fieldTail.next
fieldTail.next = field;
fieldTail = field;
}
static int count(CtMember head, CtMember tail) {
int n = 0;
while (head != tail) {
n++;
head = head.next;
}
return n;
}
void remove(CtMember mem) {
CtMember m = this;
CtMember node;
while ((node = m.next) != this) {
if (node == mem) {
m.next = node.next;
if (node == methodTail)
methodTail = m;
if (node == consTail)
consTail = m;
if (node == fieldTail)
fieldTail = m;
break;
}
m = m.next;
}
}
} | return methodTail; |
HotswapProjects_HotswapAgent | HotswapAgent/hotswap-agent-core/src/main/java/org/hotswap/agent/javassist/CtMember.java | Cache | lastCons | class Cache extends CtMember {
@Override
protected void extendToString(StringBuffer buffer) {}
@Override
public boolean hasAnnotation(String clz) { return false; }
@Override
public Object getAnnotation(Class<?> clz)
throws ClassNotFoundException { return null; }
@Override
public Object[] getAnnotations()
throws ClassNotFoundException { return null; }
@Override
public byte[] getAttribute(String name) { return null; }
@Override
public Object[] getAvailableAnnotations() { return null; }
@Override
public int getModifiers() { return 0; }
@Override
public String getName() { return null; }
@Override
public String getSignature() { return null; }
@Override
public void setAttribute(String name, byte[] data) {}
@Override
public void setModifiers(int mod) {}
@Override
public String getGenericSignature() { return null; }
@Override
public void setGenericSignature(String sig) {}
private CtMember methodTail;
private CtMember consTail; // constructor tail
private CtMember fieldTail;
Cache(CtClassType decl) {
super(decl);
methodTail = this;
consTail = this;
fieldTail = this;
fieldTail.next = this;
}
CtMember methodHead() { return this; }
CtMember lastMethod() { return methodTail; }
CtMember consHead() { return methodTail; } // may include a static initializer
CtMember lastCons() {<FILL_FUNCTION_BODY>}
CtMember fieldHead() { return consTail; }
CtMember lastField() { return fieldTail; }
void addMethod(CtMember method) {
method.next = methodTail.next;
methodTail.next = method;
if (methodTail == consTail) {
consTail = method;
if (methodTail == fieldTail)
fieldTail = method;
}
methodTail = method;
}
/* Both constructors and a class initializer.
*/
void addConstructor(CtMember cons) {
cons.next = consTail.next;
consTail.next = cons;
if (consTail == fieldTail)
fieldTail = cons;
consTail = cons;
}
void addField(CtMember field) {
field.next = this; // or fieldTail.next
fieldTail.next = field;
fieldTail = field;
}
static int count(CtMember head, CtMember tail) {
int n = 0;
while (head != tail) {
n++;
head = head.next;
}
return n;
}
void remove(CtMember mem) {
CtMember m = this;
CtMember node;
while ((node = m.next) != this) {
if (node == mem) {
m.next = node.next;
if (node == methodTail)
methodTail = m;
if (node == consTail)
consTail = m;
if (node == fieldTail)
fieldTail = m;
break;
}
m = m.next;
}
}
} | return consTail; |
HotswapProjects_HotswapAgent | HotswapAgent/hotswap-agent-core/src/main/java/org/hotswap/agent/javassist/CtMember.java | Cache | fieldHead | class Cache extends CtMember {
@Override
protected void extendToString(StringBuffer buffer) {}
@Override
public boolean hasAnnotation(String clz) { return false; }
@Override
public Object getAnnotation(Class<?> clz)
throws ClassNotFoundException { return null; }
@Override
public Object[] getAnnotations()
throws ClassNotFoundException { return null; }
@Override
public byte[] getAttribute(String name) { return null; }
@Override
public Object[] getAvailableAnnotations() { return null; }
@Override
public int getModifiers() { return 0; }
@Override
public String getName() { return null; }
@Override
public String getSignature() { return null; }
@Override
public void setAttribute(String name, byte[] data) {}
@Override
public void setModifiers(int mod) {}
@Override
public String getGenericSignature() { return null; }
@Override
public void setGenericSignature(String sig) {}
private CtMember methodTail;
private CtMember consTail; // constructor tail
private CtMember fieldTail;
Cache(CtClassType decl) {
super(decl);
methodTail = this;
consTail = this;
fieldTail = this;
fieldTail.next = this;
}
CtMember methodHead() { return this; }
CtMember lastMethod() { return methodTail; }
CtMember consHead() { return methodTail; } // may include a static initializer
CtMember lastCons() { return consTail; }
CtMember fieldHead() {<FILL_FUNCTION_BODY>}
CtMember lastField() { return fieldTail; }
void addMethod(CtMember method) {
method.next = methodTail.next;
methodTail.next = method;
if (methodTail == consTail) {
consTail = method;
if (methodTail == fieldTail)
fieldTail = method;
}
methodTail = method;
}
/* Both constructors and a class initializer.
*/
void addConstructor(CtMember cons) {
cons.next = consTail.next;
consTail.next = cons;
if (consTail == fieldTail)
fieldTail = cons;
consTail = cons;
}
void addField(CtMember field) {
field.next = this; // or fieldTail.next
fieldTail.next = field;
fieldTail = field;
}
static int count(CtMember head, CtMember tail) {
int n = 0;
while (head != tail) {
n++;
head = head.next;
}
return n;
}
void remove(CtMember mem) {
CtMember m = this;
CtMember node;
while ((node = m.next) != this) {
if (node == mem) {
m.next = node.next;
if (node == methodTail)
methodTail = m;
if (node == consTail)
consTail = m;
if (node == fieldTail)
fieldTail = m;
break;
}
m = m.next;
}
}
} | return consTail; |
HotswapProjects_HotswapAgent | HotswapAgent/hotswap-agent-core/src/main/java/org/hotswap/agent/javassist/CtMember.java | Cache | lastField | class Cache extends CtMember {
@Override
protected void extendToString(StringBuffer buffer) {}
@Override
public boolean hasAnnotation(String clz) { return false; }
@Override
public Object getAnnotation(Class<?> clz)
throws ClassNotFoundException { return null; }
@Override
public Object[] getAnnotations()
throws ClassNotFoundException { return null; }
@Override
public byte[] getAttribute(String name) { return null; }
@Override
public Object[] getAvailableAnnotations() { return null; }
@Override
public int getModifiers() { return 0; }
@Override
public String getName() { return null; }
@Override
public String getSignature() { return null; }
@Override
public void setAttribute(String name, byte[] data) {}
@Override
public void setModifiers(int mod) {}
@Override
public String getGenericSignature() { return null; }
@Override
public void setGenericSignature(String sig) {}
private CtMember methodTail;
private CtMember consTail; // constructor tail
private CtMember fieldTail;
Cache(CtClassType decl) {
super(decl);
methodTail = this;
consTail = this;
fieldTail = this;
fieldTail.next = this;
}
CtMember methodHead() { return this; }
CtMember lastMethod() { return methodTail; }
CtMember consHead() { return methodTail; } // may include a static initializer
CtMember lastCons() { return consTail; }
CtMember fieldHead() { return consTail; }
CtMember lastField() {<FILL_FUNCTION_BODY>}
void addMethod(CtMember method) {
method.next = methodTail.next;
methodTail.next = method;
if (methodTail == consTail) {
consTail = method;
if (methodTail == fieldTail)
fieldTail = method;
}
methodTail = method;
}
/* Both constructors and a class initializer.
*/
void addConstructor(CtMember cons) {
cons.next = consTail.next;
consTail.next = cons;
if (consTail == fieldTail)
fieldTail = cons;
consTail = cons;
}
void addField(CtMember field) {
field.next = this; // or fieldTail.next
fieldTail.next = field;
fieldTail = field;
}
static int count(CtMember head, CtMember tail) {
int n = 0;
while (head != tail) {
n++;
head = head.next;
}
return n;
}
void remove(CtMember mem) {
CtMember m = this;
CtMember node;
while ((node = m.next) != this) {
if (node == mem) {
m.next = node.next;
if (node == methodTail)
methodTail = m;
if (node == consTail)
consTail = m;
if (node == fieldTail)
fieldTail = m;
break;
}
m = m.next;
}
}
} | return fieldTail; |
HotswapProjects_HotswapAgent | HotswapAgent/hotswap-agent-core/src/main/java/org/hotswap/agent/javassist/CtMember.java | Cache | addMethod | class Cache extends CtMember {
@Override
protected void extendToString(StringBuffer buffer) {}
@Override
public boolean hasAnnotation(String clz) { return false; }
@Override
public Object getAnnotation(Class<?> clz)
throws ClassNotFoundException { return null; }
@Override
public Object[] getAnnotations()
throws ClassNotFoundException { return null; }
@Override
public byte[] getAttribute(String name) { return null; }
@Override
public Object[] getAvailableAnnotations() { return null; }
@Override
public int getModifiers() { return 0; }
@Override
public String getName() { return null; }
@Override
public String getSignature() { return null; }
@Override
public void setAttribute(String name, byte[] data) {}
@Override
public void setModifiers(int mod) {}
@Override
public String getGenericSignature() { return null; }
@Override
public void setGenericSignature(String sig) {}
private CtMember methodTail;
private CtMember consTail; // constructor tail
private CtMember fieldTail;
Cache(CtClassType decl) {
super(decl);
methodTail = this;
consTail = this;
fieldTail = this;
fieldTail.next = this;
}
CtMember methodHead() { return this; }
CtMember lastMethod() { return methodTail; }
CtMember consHead() { return methodTail; } // may include a static initializer
CtMember lastCons() { return consTail; }
CtMember fieldHead() { return consTail; }
CtMember lastField() { return fieldTail; }
void addMethod(CtMember method) {<FILL_FUNCTION_BODY>}
/* Both constructors and a class initializer.
*/
void addConstructor(CtMember cons) {
cons.next = consTail.next;
consTail.next = cons;
if (consTail == fieldTail)
fieldTail = cons;
consTail = cons;
}
void addField(CtMember field) {
field.next = this; // or fieldTail.next
fieldTail.next = field;
fieldTail = field;
}
static int count(CtMember head, CtMember tail) {
int n = 0;
while (head != tail) {
n++;
head = head.next;
}
return n;
}
void remove(CtMember mem) {
CtMember m = this;
CtMember node;
while ((node = m.next) != this) {
if (node == mem) {
m.next = node.next;
if (node == methodTail)
methodTail = m;
if (node == consTail)
consTail = m;
if (node == fieldTail)
fieldTail = m;
break;
}
m = m.next;
}
}
} |
method.next = methodTail.next;
methodTail.next = method;
if (methodTail == consTail) {
consTail = method;
if (methodTail == fieldTail)
fieldTail = method;
}
methodTail = method;
|
HotswapProjects_HotswapAgent | HotswapAgent/hotswap-agent-core/src/main/java/org/hotswap/agent/javassist/CtMember.java | Cache | addConstructor | class Cache extends CtMember {
@Override
protected void extendToString(StringBuffer buffer) {}
@Override
public boolean hasAnnotation(String clz) { return false; }
@Override
public Object getAnnotation(Class<?> clz)
throws ClassNotFoundException { return null; }
@Override
public Object[] getAnnotations()
throws ClassNotFoundException { return null; }
@Override
public byte[] getAttribute(String name) { return null; }
@Override
public Object[] getAvailableAnnotations() { return null; }
@Override
public int getModifiers() { return 0; }
@Override
public String getName() { return null; }
@Override
public String getSignature() { return null; }
@Override
public void setAttribute(String name, byte[] data) {}
@Override
public void setModifiers(int mod) {}
@Override
public String getGenericSignature() { return null; }
@Override
public void setGenericSignature(String sig) {}
private CtMember methodTail;
private CtMember consTail; // constructor tail
private CtMember fieldTail;
Cache(CtClassType decl) {
super(decl);
methodTail = this;
consTail = this;
fieldTail = this;
fieldTail.next = this;
}
CtMember methodHead() { return this; }
CtMember lastMethod() { return methodTail; }
CtMember consHead() { return methodTail; } // may include a static initializer
CtMember lastCons() { return consTail; }
CtMember fieldHead() { return consTail; }
CtMember lastField() { return fieldTail; }
void addMethod(CtMember method) {
method.next = methodTail.next;
methodTail.next = method;
if (methodTail == consTail) {
consTail = method;
if (methodTail == fieldTail)
fieldTail = method;
}
methodTail = method;
}
/* Both constructors and a class initializer.
*/
void addConstructor(CtMember cons) {<FILL_FUNCTION_BODY>}
void addField(CtMember field) {
field.next = this; // or fieldTail.next
fieldTail.next = field;
fieldTail = field;
}
static int count(CtMember head, CtMember tail) {
int n = 0;
while (head != tail) {
n++;
head = head.next;
}
return n;
}
void remove(CtMember mem) {
CtMember m = this;
CtMember node;
while ((node = m.next) != this) {
if (node == mem) {
m.next = node.next;
if (node == methodTail)
methodTail = m;
if (node == consTail)
consTail = m;
if (node == fieldTail)
fieldTail = m;
break;
}
m = m.next;
}
}
} |
cons.next = consTail.next;
consTail.next = cons;
if (consTail == fieldTail)
fieldTail = cons;
consTail = cons;
|
HotswapProjects_HotswapAgent | HotswapAgent/hotswap-agent-core/src/main/java/org/hotswap/agent/javassist/CtMember.java | Cache | addField | class Cache extends CtMember {
@Override
protected void extendToString(StringBuffer buffer) {}
@Override
public boolean hasAnnotation(String clz) { return false; }
@Override
public Object getAnnotation(Class<?> clz)
throws ClassNotFoundException { return null; }
@Override
public Object[] getAnnotations()
throws ClassNotFoundException { return null; }
@Override
public byte[] getAttribute(String name) { return null; }
@Override
public Object[] getAvailableAnnotations() { return null; }
@Override
public int getModifiers() { return 0; }
@Override
public String getName() { return null; }
@Override
public String getSignature() { return null; }
@Override
public void setAttribute(String name, byte[] data) {}
@Override
public void setModifiers(int mod) {}
@Override
public String getGenericSignature() { return null; }
@Override
public void setGenericSignature(String sig) {}
private CtMember methodTail;
private CtMember consTail; // constructor tail
private CtMember fieldTail;
Cache(CtClassType decl) {
super(decl);
methodTail = this;
consTail = this;
fieldTail = this;
fieldTail.next = this;
}
CtMember methodHead() { return this; }
CtMember lastMethod() { return methodTail; }
CtMember consHead() { return methodTail; } // may include a static initializer
CtMember lastCons() { return consTail; }
CtMember fieldHead() { return consTail; }
CtMember lastField() { return fieldTail; }
void addMethod(CtMember method) {
method.next = methodTail.next;
methodTail.next = method;
if (methodTail == consTail) {
consTail = method;
if (methodTail == fieldTail)
fieldTail = method;
}
methodTail = method;
}
/* Both constructors and a class initializer.
*/
void addConstructor(CtMember cons) {
cons.next = consTail.next;
consTail.next = cons;
if (consTail == fieldTail)
fieldTail = cons;
consTail = cons;
}
void addField(CtMember field) {<FILL_FUNCTION_BODY>}
static int count(CtMember head, CtMember tail) {
int n = 0;
while (head != tail) {
n++;
head = head.next;
}
return n;
}
void remove(CtMember mem) {
CtMember m = this;
CtMember node;
while ((node = m.next) != this) {
if (node == mem) {
m.next = node.next;
if (node == methodTail)
methodTail = m;
if (node == consTail)
consTail = m;
if (node == fieldTail)
fieldTail = m;
break;
}
m = m.next;
}
}
} |
field.next = this; // or fieldTail.next
fieldTail.next = field;
fieldTail = field;
|
HotswapProjects_HotswapAgent | HotswapAgent/hotswap-agent-core/src/main/java/org/hotswap/agent/javassist/CtMember.java | Cache | count | class Cache extends CtMember {
@Override
protected void extendToString(StringBuffer buffer) {}
@Override
public boolean hasAnnotation(String clz) { return false; }
@Override
public Object getAnnotation(Class<?> clz)
throws ClassNotFoundException { return null; }
@Override
public Object[] getAnnotations()
throws ClassNotFoundException { return null; }
@Override
public byte[] getAttribute(String name) { return null; }
@Override
public Object[] getAvailableAnnotations() { return null; }
@Override
public int getModifiers() { return 0; }
@Override
public String getName() { return null; }
@Override
public String getSignature() { return null; }
@Override
public void setAttribute(String name, byte[] data) {}
@Override
public void setModifiers(int mod) {}
@Override
public String getGenericSignature() { return null; }
@Override
public void setGenericSignature(String sig) {}
private CtMember methodTail;
private CtMember consTail; // constructor tail
private CtMember fieldTail;
Cache(CtClassType decl) {
super(decl);
methodTail = this;
consTail = this;
fieldTail = this;
fieldTail.next = this;
}
CtMember methodHead() { return this; }
CtMember lastMethod() { return methodTail; }
CtMember consHead() { return methodTail; } // may include a static initializer
CtMember lastCons() { return consTail; }
CtMember fieldHead() { return consTail; }
CtMember lastField() { return fieldTail; }
void addMethod(CtMember method) {
method.next = methodTail.next;
methodTail.next = method;
if (methodTail == consTail) {
consTail = method;
if (methodTail == fieldTail)
fieldTail = method;
}
methodTail = method;
}
/* Both constructors and a class initializer.
*/
void addConstructor(CtMember cons) {
cons.next = consTail.next;
consTail.next = cons;
if (consTail == fieldTail)
fieldTail = cons;
consTail = cons;
}
void addField(CtMember field) {
field.next = this; // or fieldTail.next
fieldTail.next = field;
fieldTail = field;
}
static int count(CtMember head, CtMember tail) {<FILL_FUNCTION_BODY>}
void remove(CtMember mem) {
CtMember m = this;
CtMember node;
while ((node = m.next) != this) {
if (node == mem) {
m.next = node.next;
if (node == methodTail)
methodTail = m;
if (node == consTail)
consTail = m;
if (node == fieldTail)
fieldTail = m;
break;
}
m = m.next;
}
}
} |
int n = 0;
while (head != tail) {
n++;
head = head.next;
}
return n;
|
HotswapProjects_HotswapAgent | HotswapAgent/hotswap-agent-core/src/main/java/org/hotswap/agent/javassist/CtMember.java | Cache | remove | class Cache extends CtMember {
@Override
protected void extendToString(StringBuffer buffer) {}
@Override
public boolean hasAnnotation(String clz) { return false; }
@Override
public Object getAnnotation(Class<?> clz)
throws ClassNotFoundException { return null; }
@Override
public Object[] getAnnotations()
throws ClassNotFoundException { return null; }
@Override
public byte[] getAttribute(String name) { return null; }
@Override
public Object[] getAvailableAnnotations() { return null; }
@Override
public int getModifiers() { return 0; }
@Override
public String getName() { return null; }
@Override
public String getSignature() { return null; }
@Override
public void setAttribute(String name, byte[] data) {}
@Override
public void setModifiers(int mod) {}
@Override
public String getGenericSignature() { return null; }
@Override
public void setGenericSignature(String sig) {}
private CtMember methodTail;
private CtMember consTail; // constructor tail
private CtMember fieldTail;
Cache(CtClassType decl) {
super(decl);
methodTail = this;
consTail = this;
fieldTail = this;
fieldTail.next = this;
}
CtMember methodHead() { return this; }
CtMember lastMethod() { return methodTail; }
CtMember consHead() { return methodTail; } // may include a static initializer
CtMember lastCons() { return consTail; }
CtMember fieldHead() { return consTail; }
CtMember lastField() { return fieldTail; }
void addMethod(CtMember method) {
method.next = methodTail.next;
methodTail.next = method;
if (methodTail == consTail) {
consTail = method;
if (methodTail == fieldTail)
fieldTail = method;
}
methodTail = method;
}
/* Both constructors and a class initializer.
*/
void addConstructor(CtMember cons) {
cons.next = consTail.next;
consTail.next = cons;
if (consTail == fieldTail)
fieldTail = cons;
consTail = cons;
}
void addField(CtMember field) {
field.next = this; // or fieldTail.next
fieldTail.next = field;
fieldTail = field;
}
static int count(CtMember head, CtMember tail) {
int n = 0;
while (head != tail) {
n++;
head = head.next;
}
return n;
}
void remove(CtMember mem) {<FILL_FUNCTION_BODY>}
} |
CtMember m = this;
CtMember node;
while ((node = m.next) != this) {
if (node == mem) {
m.next = node.next;
if (node == methodTail)
methodTail = m;
if (node == consTail)
consTail = m;
if (node == fieldTail)
fieldTail = m;
break;
}
m = m.next;
}
|
HotswapProjects_HotswapAgent | HotswapAgent/hotswap-agent-core/src/main/java/org/hotswap/agent/javassist/CtMember.java | Cache | next | class Cache extends CtMember {
@Override
protected void extendToString(StringBuffer buffer) {}
@Override
public boolean hasAnnotation(String clz) { return false; }
@Override
public Object getAnnotation(Class<?> clz)
throws ClassNotFoundException { return null; }
@Override
public Object[] getAnnotations()
throws ClassNotFoundException { return null; }
@Override
public byte[] getAttribute(String name) { return null; }
@Override
public Object[] getAvailableAnnotations() { return null; }
@Override
public int getModifiers() { return 0; }
@Override
public String getName() { return null; }
@Override
public String getSignature() { return null; }
@Override
public void setAttribute(String name, byte[] data) {}
@Override
public void setModifiers(int mod) {}
@Override
public String getGenericSignature() { return null; }
@Override
public void setGenericSignature(String sig) {}
private CtMember methodTail;
private CtMember consTail; // constructor tail
private CtMember fieldTail;
Cache(CtClassType decl) {
super(decl);
methodTail = this;
consTail = this;
fieldTail = this;
fieldTail.next = this;
}
CtMember methodHead() { return this; }
CtMember lastMethod() { return methodTail; }
CtMember consHead() { return methodTail; } // may include a static initializer
CtMember lastCons() { return consTail; }
CtMember fieldHead() { return consTail; }
CtMember lastField() { return fieldTail; }
void addMethod(CtMember method) {
method.next = methodTail.next;
methodTail.next = method;
if (methodTail == consTail) {
consTail = method;
if (methodTail == fieldTail)
fieldTail = method;
}
methodTail = method;
}
/* Both constructors and a class initializer.
*/
void addConstructor(CtMember cons) {
cons.next = consTail.next;
consTail.next = cons;
if (consTail == fieldTail)
fieldTail = cons;
consTail = cons;
}
void addField(CtMember field) {
field.next = this; // or fieldTail.next
fieldTail.next = field;
fieldTail = field;
}
static int count(CtMember head, CtMember tail) {
int n = 0;
while (head != tail) {
n++;
head = head.next;
}
return n;
}
void remove(CtMember mem) {
CtMember m = this;
CtMember node;
while ((node = m.next) != this) {
if (node == mem) {
m.next = node.next;
if (node == methodTail)
methodTail = m;
if (node == consTail)
consTail = m;
if (node == fieldTail)
fieldTail = m;
break;
}
m = m.next;
}
}
}
protected CtMember(CtClass clazz) {
declaringClass = clazz;
next = null;
}
final CtMember next() {<FILL_FUNCTION_BODY> | return next; |
HotswapProjects_HotswapAgent | HotswapAgent/hotswap-agent-core/src/main/java/org/hotswap/agent/javassist/CtMember.java | Cache | nameReplaced | class Cache extends CtMember {
@Override
protected void extendToString(StringBuffer buffer) {}
@Override
public boolean hasAnnotation(String clz) { return false; }
@Override
public Object getAnnotation(Class<?> clz)
throws ClassNotFoundException { return null; }
@Override
public Object[] getAnnotations()
throws ClassNotFoundException { return null; }
@Override
public byte[] getAttribute(String name) { return null; }
@Override
public Object[] getAvailableAnnotations() { return null; }
@Override
public int getModifiers() { return 0; }
@Override
public String getName() { return null; }
@Override
public String getSignature() { return null; }
@Override
public void setAttribute(String name, byte[] data) {}
@Override
public void setModifiers(int mod) {}
@Override
public String getGenericSignature() { return null; }
@Override
public void setGenericSignature(String sig) {}
private CtMember methodTail;
private CtMember consTail; // constructor tail
private CtMember fieldTail;
Cache(CtClassType decl) {
super(decl);
methodTail = this;
consTail = this;
fieldTail = this;
fieldTail.next = this;
}
CtMember methodHead() { return this; }
CtMember lastMethod() { return methodTail; }
CtMember consHead() { return methodTail; } // may include a static initializer
CtMember lastCons() { return consTail; }
CtMember fieldHead() { return consTail; }
CtMember lastField() { return fieldTail; }
void addMethod(CtMember method) {
method.next = methodTail.next;
methodTail.next = method;
if (methodTail == consTail) {
consTail = method;
if (methodTail == fieldTail)
fieldTail = method;
}
methodTail = method;
}
/* Both constructors and a class initializer.
*/
void addConstructor(CtMember cons) {
cons.next = consTail.next;
consTail.next = cons;
if (consTail == fieldTail)
fieldTail = cons;
consTail = cons;
}
void addField(CtMember field) {
field.next = this; // or fieldTail.next
fieldTail.next = field;
fieldTail = field;
}
static int count(CtMember head, CtMember tail) {
int n = 0;
while (head != tail) {
n++;
head = head.next;
}
return n;
}
void remove(CtMember mem) {
CtMember m = this;
CtMember node;
while ((node = m.next) != this) {
if (node == mem) {
m.next = node.next;
if (node == methodTail)
methodTail = m;
if (node == consTail)
consTail = m;
if (node == fieldTail)
fieldTail = m;
break;
}
m = m.next;
}
}
}
protected CtMember(CtClass clazz) {
declaringClass = clazz;
next = null;
}
final CtMember next() { return next; }
/**
* This method is invoked when setName() or replaceClassName()
* in CtClass is called.
*
* @see CtMethod#nameReplaced()
*/
void nameReplaced() {<FILL_FUNCTION_BODY> | |
HotswapProjects_HotswapAgent | HotswapAgent/hotswap-agent-core/src/main/java/org/hotswap/agent/javassist/CtMember.java | Cache | toString | class Cache extends CtMember {
@Override
protected void extendToString(StringBuffer buffer) {}
@Override
public boolean hasAnnotation(String clz) { return false; }
@Override
public Object getAnnotation(Class<?> clz)
throws ClassNotFoundException { return null; }
@Override
public Object[] getAnnotations()
throws ClassNotFoundException { return null; }
@Override
public byte[] getAttribute(String name) { return null; }
@Override
public Object[] getAvailableAnnotations() { return null; }
@Override
public int getModifiers() { return 0; }
@Override
public String getName() { return null; }
@Override
public String getSignature() { return null; }
@Override
public void setAttribute(String name, byte[] data) {}
@Override
public void setModifiers(int mod) {}
@Override
public String getGenericSignature() { return null; }
@Override
public void setGenericSignature(String sig) {}
private CtMember methodTail;
private CtMember consTail; // constructor tail
private CtMember fieldTail;
Cache(CtClassType decl) {
super(decl);
methodTail = this;
consTail = this;
fieldTail = this;
fieldTail.next = this;
}
CtMember methodHead() { return this; }
CtMember lastMethod() { return methodTail; }
CtMember consHead() { return methodTail; } // may include a static initializer
CtMember lastCons() { return consTail; }
CtMember fieldHead() { return consTail; }
CtMember lastField() { return fieldTail; }
void addMethod(CtMember method) {
method.next = methodTail.next;
methodTail.next = method;
if (methodTail == consTail) {
consTail = method;
if (methodTail == fieldTail)
fieldTail = method;
}
methodTail = method;
}
/* Both constructors and a class initializer.
*/
void addConstructor(CtMember cons) {
cons.next = consTail.next;
consTail.next = cons;
if (consTail == fieldTail)
fieldTail = cons;
consTail = cons;
}
void addField(CtMember field) {
field.next = this; // or fieldTail.next
fieldTail.next = field;
fieldTail = field;
}
static int count(CtMember head, CtMember tail) {
int n = 0;
while (head != tail) {
n++;
head = head.next;
}
return n;
}
void remove(CtMember mem) {
CtMember m = this;
CtMember node;
while ((node = m.next) != this) {
if (node == mem) {
m.next = node.next;
if (node == methodTail)
methodTail = m;
if (node == consTail)
consTail = m;
if (node == fieldTail)
fieldTail = m;
break;
}
m = m.next;
}
}
}
protected CtMember(CtClass clazz) {
declaringClass = clazz;
next = null;
}
final CtMember next() { return next; }
/**
* This method is invoked when setName() or replaceClassName()
* in CtClass is called.
*
* @see CtMethod#nameReplaced()
*/
void nameReplaced() {}
@Override
public String toString() {<FILL_FUNCTION_BODY> |
StringBuffer buffer = new StringBuffer(getClass().getName());
buffer.append("@");
buffer.append(Integer.toHexString(hashCode()));
buffer.append("[");
buffer.append(Modifier.toString(getModifiers()));
extendToString(buffer);
buffer.append("]");
return buffer.toString();
|
HotswapProjects_HotswapAgent | HotswapAgent/hotswap-agent-core/src/main/java/org/hotswap/agent/javassist/CtMember.java | Cache | getDeclaringClass | class Cache extends CtMember {
@Override
protected void extendToString(StringBuffer buffer) {}
@Override
public boolean hasAnnotation(String clz) { return false; }
@Override
public Object getAnnotation(Class<?> clz)
throws ClassNotFoundException { return null; }
@Override
public Object[] getAnnotations()
throws ClassNotFoundException { return null; }
@Override
public byte[] getAttribute(String name) { return null; }
@Override
public Object[] getAvailableAnnotations() { return null; }
@Override
public int getModifiers() { return 0; }
@Override
public String getName() { return null; }
@Override
public String getSignature() { return null; }
@Override
public void setAttribute(String name, byte[] data) {}
@Override
public void setModifiers(int mod) {}
@Override
public String getGenericSignature() { return null; }
@Override
public void setGenericSignature(String sig) {}
private CtMember methodTail;
private CtMember consTail; // constructor tail
private CtMember fieldTail;
Cache(CtClassType decl) {
super(decl);
methodTail = this;
consTail = this;
fieldTail = this;
fieldTail.next = this;
}
CtMember methodHead() { return this; }
CtMember lastMethod() { return methodTail; }
CtMember consHead() { return methodTail; } // may include a static initializer
CtMember lastCons() { return consTail; }
CtMember fieldHead() { return consTail; }
CtMember lastField() { return fieldTail; }
void addMethod(CtMember method) {
method.next = methodTail.next;
methodTail.next = method;
if (methodTail == consTail) {
consTail = method;
if (methodTail == fieldTail)
fieldTail = method;
}
methodTail = method;
}
/* Both constructors and a class initializer.
*/
void addConstructor(CtMember cons) {
cons.next = consTail.next;
consTail.next = cons;
if (consTail == fieldTail)
fieldTail = cons;
consTail = cons;
}
void addField(CtMember field) {
field.next = this; // or fieldTail.next
fieldTail.next = field;
fieldTail = field;
}
static int count(CtMember head, CtMember tail) {
int n = 0;
while (head != tail) {
n++;
head = head.next;
}
return n;
}
void remove(CtMember mem) {
CtMember m = this;
CtMember node;
while ((node = m.next) != this) {
if (node == mem) {
m.next = node.next;
if (node == methodTail)
methodTail = m;
if (node == consTail)
consTail = m;
if (node == fieldTail)
fieldTail = m;
break;
}
m = m.next;
}
}
}
protected CtMember(CtClass clazz) {
declaringClass = clazz;
next = null;
}
final CtMember next() { return next; }
/**
* This method is invoked when setName() or replaceClassName()
* in CtClass is called.
*
* @see CtMethod#nameReplaced()
*/
void nameReplaced() {}
@Override
public String toString() {
StringBuffer buffer = new StringBuffer(getClass().getName());
buffer.append("@");
buffer.append(Integer.toHexString(hashCode()));
buffer.append("[");
buffer.append(Modifier.toString(getModifiers()));
extendToString(buffer);
buffer.append("]");
return buffer.toString();
}
/**
* Invoked by {@link #toString()} to add to the buffer and provide the
* complete value. Subclasses should invoke this method, adding a
* space before each token. The modifiers for the member are
* provided first; subclasses should provide additional data such
* as return type, field or method name, etc.
*/
protected abstract void extendToString(StringBuffer buffer);
/**
* Returns the class that declares this member.
*/
public CtClass getDeclaringClass() {<FILL_FUNCTION_BODY> | return declaringClass; |
HotswapProjects_HotswapAgent | HotswapAgent/hotswap-agent-core/src/main/java/org/hotswap/agent/javassist/CtMember.java | Cache | visibleFrom | class Cache extends CtMember {
@Override
protected void extendToString(StringBuffer buffer) {}
@Override
public boolean hasAnnotation(String clz) { return false; }
@Override
public Object getAnnotation(Class<?> clz)
throws ClassNotFoundException { return null; }
@Override
public Object[] getAnnotations()
throws ClassNotFoundException { return null; }
@Override
public byte[] getAttribute(String name) { return null; }
@Override
public Object[] getAvailableAnnotations() { return null; }
@Override
public int getModifiers() { return 0; }
@Override
public String getName() { return null; }
@Override
public String getSignature() { return null; }
@Override
public void setAttribute(String name, byte[] data) {}
@Override
public void setModifiers(int mod) {}
@Override
public String getGenericSignature() { return null; }
@Override
public void setGenericSignature(String sig) {}
private CtMember methodTail;
private CtMember consTail; // constructor tail
private CtMember fieldTail;
Cache(CtClassType decl) {
super(decl);
methodTail = this;
consTail = this;
fieldTail = this;
fieldTail.next = this;
}
CtMember methodHead() { return this; }
CtMember lastMethod() { return methodTail; }
CtMember consHead() { return methodTail; } // may include a static initializer
CtMember lastCons() { return consTail; }
CtMember fieldHead() { return consTail; }
CtMember lastField() { return fieldTail; }
void addMethod(CtMember method) {
method.next = methodTail.next;
methodTail.next = method;
if (methodTail == consTail) {
consTail = method;
if (methodTail == fieldTail)
fieldTail = method;
}
methodTail = method;
}
/* Both constructors and a class initializer.
*/
void addConstructor(CtMember cons) {
cons.next = consTail.next;
consTail.next = cons;
if (consTail == fieldTail)
fieldTail = cons;
consTail = cons;
}
void addField(CtMember field) {
field.next = this; // or fieldTail.next
fieldTail.next = field;
fieldTail = field;
}
static int count(CtMember head, CtMember tail) {
int n = 0;
while (head != tail) {
n++;
head = head.next;
}
return n;
}
void remove(CtMember mem) {
CtMember m = this;
CtMember node;
while ((node = m.next) != this) {
if (node == mem) {
m.next = node.next;
if (node == methodTail)
methodTail = m;
if (node == consTail)
consTail = m;
if (node == fieldTail)
fieldTail = m;
break;
}
m = m.next;
}
}
}
protected CtMember(CtClass clazz) {
declaringClass = clazz;
next = null;
}
final CtMember next() { return next; }
/**
* This method is invoked when setName() or replaceClassName()
* in CtClass is called.
*
* @see CtMethod#nameReplaced()
*/
void nameReplaced() {}
@Override
public String toString() {
StringBuffer buffer = new StringBuffer(getClass().getName());
buffer.append("@");
buffer.append(Integer.toHexString(hashCode()));
buffer.append("[");
buffer.append(Modifier.toString(getModifiers()));
extendToString(buffer);
buffer.append("]");
return buffer.toString();
}
/**
* Invoked by {@link #toString()} to add to the buffer and provide the
* complete value. Subclasses should invoke this method, adding a
* space before each token. The modifiers for the member are
* provided first; subclasses should provide additional data such
* as return type, field or method name, etc.
*/
protected abstract void extendToString(StringBuffer buffer);
/**
* Returns the class that declares this member.
*/
public CtClass getDeclaringClass() { return declaringClass; }
/**
* Returns true if this member is accessible from the given class.
*/
public boolean visibleFrom(CtClass clazz) {<FILL_FUNCTION_BODY> |
int mod = getModifiers();
if (Modifier.isPublic(mod))
return true;
else if (Modifier.isPrivate(mod))
return clazz == declaringClass;
else { // package or protected
String declName = declaringClass.getPackageName();
String fromName = clazz.getPackageName();
boolean visible;
if (declName == null)
visible = fromName == null;
else
visible = declName.equals(fromName);
if (!visible && Modifier.isProtected(mod))
return clazz.subclassOf(declaringClass);
return visible;
}
|
HotswapProjects_HotswapAgent | HotswapAgent/hotswap-agent-core/src/main/java/org/hotswap/agent/javassist/CtMember.java | Cache | hasAnnotation | class Cache extends CtMember {
@Override
protected void extendToString(StringBuffer buffer) {}
@Override
public boolean hasAnnotation(String clz) { return false; }
@Override
public Object getAnnotation(Class<?> clz)
throws ClassNotFoundException { return null; }
@Override
public Object[] getAnnotations()
throws ClassNotFoundException { return null; }
@Override
public byte[] getAttribute(String name) { return null; }
@Override
public Object[] getAvailableAnnotations() { return null; }
@Override
public int getModifiers() { return 0; }
@Override
public String getName() { return null; }
@Override
public String getSignature() { return null; }
@Override
public void setAttribute(String name, byte[] data) {}
@Override
public void setModifiers(int mod) {}
@Override
public String getGenericSignature() { return null; }
@Override
public void setGenericSignature(String sig) {}
private CtMember methodTail;
private CtMember consTail; // constructor tail
private CtMember fieldTail;
Cache(CtClassType decl) {
super(decl);
methodTail = this;
consTail = this;
fieldTail = this;
fieldTail.next = this;
}
CtMember methodHead() { return this; }
CtMember lastMethod() { return methodTail; }
CtMember consHead() { return methodTail; } // may include a static initializer
CtMember lastCons() { return consTail; }
CtMember fieldHead() { return consTail; }
CtMember lastField() { return fieldTail; }
void addMethod(CtMember method) {
method.next = methodTail.next;
methodTail.next = method;
if (methodTail == consTail) {
consTail = method;
if (methodTail == fieldTail)
fieldTail = method;
}
methodTail = method;
}
/* Both constructors and a class initializer.
*/
void addConstructor(CtMember cons) {
cons.next = consTail.next;
consTail.next = cons;
if (consTail == fieldTail)
fieldTail = cons;
consTail = cons;
}
void addField(CtMember field) {
field.next = this; // or fieldTail.next
fieldTail.next = field;
fieldTail = field;
}
static int count(CtMember head, CtMember tail) {
int n = 0;
while (head != tail) {
n++;
head = head.next;
}
return n;
}
void remove(CtMember mem) {
CtMember m = this;
CtMember node;
while ((node = m.next) != this) {
if (node == mem) {
m.next = node.next;
if (node == methodTail)
methodTail = m;
if (node == consTail)
consTail = m;
if (node == fieldTail)
fieldTail = m;
break;
}
m = m.next;
}
}
}
protected CtMember(CtClass clazz) {
declaringClass = clazz;
next = null;
}
final CtMember next() { return next; }
/**
* This method is invoked when setName() or replaceClassName()
* in CtClass is called.
*
* @see CtMethod#nameReplaced()
*/
void nameReplaced() {}
@Override
public String toString() {
StringBuffer buffer = new StringBuffer(getClass().getName());
buffer.append("@");
buffer.append(Integer.toHexString(hashCode()));
buffer.append("[");
buffer.append(Modifier.toString(getModifiers()));
extendToString(buffer);
buffer.append("]");
return buffer.toString();
}
/**
* Invoked by {@link #toString()} to add to the buffer and provide the
* complete value. Subclasses should invoke this method, adding a
* space before each token. The modifiers for the member are
* provided first; subclasses should provide additional data such
* as return type, field or method name, etc.
*/
protected abstract void extendToString(StringBuffer buffer);
/**
* Returns the class that declares this member.
*/
public CtClass getDeclaringClass() { return declaringClass; }
/**
* Returns true if this member is accessible from the given class.
*/
public boolean visibleFrom(CtClass clazz) {
int mod = getModifiers();
if (Modifier.isPublic(mod))
return true;
else if (Modifier.isPrivate(mod))
return clazz == declaringClass;
else { // package or protected
String declName = declaringClass.getPackageName();
String fromName = clazz.getPackageName();
boolean visible;
if (declName == null)
visible = fromName == null;
else
visible = declName.equals(fromName);
if (!visible && Modifier.isProtected(mod))
return clazz.subclassOf(declaringClass);
return visible;
}
}
/**
* Obtains the modifiers of the member.
*
* @return modifiers encoded with
* <code>javassist.Modifier</code>.
* @see Modifier
*/
public abstract int getModifiers();
/**
* Sets the encoded modifiers of the member.
*
* @see Modifier
*/
public abstract void setModifiers(int mod);
/**
* Returns true if the class has the specified annotation type.
*
* @param clz the annotation type.
* @return <code>true</code> if the annotation is found, otherwise <code>false</code>.
* @since 3.11
*/
public boolean hasAnnotation(Class<?> clz) {<FILL_FUNCTION_BODY> |
return hasAnnotation(clz.getName());
|
HotswapProjects_HotswapAgent | HotswapAgent/hotswap-agent-core/src/main/java/org/hotswap/agent/javassist/bytecode/BootstrapMethodsAttribute.java | BootstrapMethod | getMethods | class BootstrapMethod {
/**
* Constructs an element of <code>bootstrap_methods</code>.
*
* @param method <code>bootstrap_method_ref</code>.
* @param args <code>bootstrap_arguments</code>.
*/
public BootstrapMethod(int method, int[] args) {
methodRef = method;
arguments = args;
}
/**
* <code>bootstrap_method_ref</code>.
* The value at this index must be a <code>CONSTANT_MethodHandle_info</code>.
*/
public int methodRef;
/**
* <code>bootstrap_arguments</code>.
*/
public int[] arguments;
}
BootstrapMethodsAttribute(ConstPool cp, int n, DataInputStream in)
throws IOException
{
super(cp, n, in);
}
/**
* Constructs a BootstrapMethods attribute.
*
* @param cp a constant pool table.
* @param methods the contents.
*/
public BootstrapMethodsAttribute(ConstPool cp, BootstrapMethod[] methods) {
super(cp, tag);
int size = 2;
for (int i = 0; i < methods.length; i++)
size += 4 + methods[i].arguments.length * 2;
byte[] data = new byte[size];
ByteArray.write16bit(methods.length, data, 0); // num_bootstrap_methods
int pos = 2;
for (int i = 0; i < methods.length; i++) {
ByteArray.write16bit(methods[i].methodRef, data, pos);
ByteArray.write16bit(methods[i].arguments.length, data, pos + 2);
int[] args = methods[i].arguments;
pos += 4;
for (int k = 0; k < args.length; k++) {
ByteArray.write16bit(args[k], data, pos);
pos += 2;
}
}
set(data);
}
/**
* Obtains <code>bootstrap_methods</code> in this attribute.
*
* @return an array of <code>BootstrapMethod</code>. Since it
* is a fresh copy, modifying the returned array does not
* affect the original contents of this attribute.
*/
public BootstrapMethod[] getMethods() {<FILL_FUNCTION_BODY> |
byte[] data = this.get();
int num = ByteArray.readU16bit(data, 0);
BootstrapMethod[] methods = new BootstrapMethod[num];
int pos = 2;
for (int i = 0; i < num; i++) {
int ref = ByteArray.readU16bit(data, pos);
int len = ByteArray.readU16bit(data, pos + 2);
int[] args = new int[len];
pos += 4;
for (int k = 0; k < len; k++) {
args[k] = ByteArray.readU16bit(data, pos);
pos += 2;
}
methods[i] = new BootstrapMethod(ref, args);
}
return methods;
|
HotswapProjects_HotswapAgent | HotswapAgent/hotswap-agent-core/src/main/java/org/hotswap/agent/javassist/bytecode/BootstrapMethodsAttribute.java | BootstrapMethod | copy | class BootstrapMethod {
/**
* Constructs an element of <code>bootstrap_methods</code>.
*
* @param method <code>bootstrap_method_ref</code>.
* @param args <code>bootstrap_arguments</code>.
*/
public BootstrapMethod(int method, int[] args) {
methodRef = method;
arguments = args;
}
/**
* <code>bootstrap_method_ref</code>.
* The value at this index must be a <code>CONSTANT_MethodHandle_info</code>.
*/
public int methodRef;
/**
* <code>bootstrap_arguments</code>.
*/
public int[] arguments;
}
BootstrapMethodsAttribute(ConstPool cp, int n, DataInputStream in)
throws IOException
{
super(cp, n, in);
}
/**
* Constructs a BootstrapMethods attribute.
*
* @param cp a constant pool table.
* @param methods the contents.
*/
public BootstrapMethodsAttribute(ConstPool cp, BootstrapMethod[] methods) {
super(cp, tag);
int size = 2;
for (int i = 0; i < methods.length; i++)
size += 4 + methods[i].arguments.length * 2;
byte[] data = new byte[size];
ByteArray.write16bit(methods.length, data, 0); // num_bootstrap_methods
int pos = 2;
for (int i = 0; i < methods.length; i++) {
ByteArray.write16bit(methods[i].methodRef, data, pos);
ByteArray.write16bit(methods[i].arguments.length, data, pos + 2);
int[] args = methods[i].arguments;
pos += 4;
for (int k = 0; k < args.length; k++) {
ByteArray.write16bit(args[k], data, pos);
pos += 2;
}
}
set(data);
}
/**
* Obtains <code>bootstrap_methods</code> in this attribute.
*
* @return an array of <code>BootstrapMethod</code>. Since it
* is a fresh copy, modifying the returned array does not
* affect the original contents of this attribute.
*/
public BootstrapMethod[] getMethods() {
byte[] data = this.get();
int num = ByteArray.readU16bit(data, 0);
BootstrapMethod[] methods = new BootstrapMethod[num];
int pos = 2;
for (int i = 0; i < num; i++) {
int ref = ByteArray.readU16bit(data, pos);
int len = ByteArray.readU16bit(data, pos + 2);
int[] args = new int[len];
pos += 4;
for (int k = 0; k < len; k++) {
args[k] = ByteArray.readU16bit(data, pos);
pos += 2;
}
methods[i] = new BootstrapMethod(ref, args);
}
return methods;
}
/**
* Makes a copy. Class names are replaced according to the
* given <code>Map</code> object.
*
* @param newCp the constant pool table used by the new copy.
* @param classnames pairs of replaced and substituted
* class names.
*/
@Override
public AttributeInfo copy(ConstPool newCp, Map<String,String> classnames) {<FILL_FUNCTION_BODY> |
BootstrapMethod[] methods = getMethods();
ConstPool thisCp = getConstPool();
for (int i = 0; i < methods.length; i++) {
BootstrapMethod m = methods[i];
m.methodRef = thisCp.copy(m.methodRef, newCp, classnames);
for (int k = 0; k < m.arguments.length; k++)
m.arguments[k] = thisCp.copy(m.arguments[k], newCp, classnames);
}
return new BootstrapMethodsAttribute(newCp, methods);
|