http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1b0e45a2/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientMessageWrapper.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientMessageWrapper.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientMessageWrapper.java new file mode 100644 index 0000000..6ff66ce --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientMessageWrapper.java @@ -0,0 +1,266 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal.processors.rest.client.message; + +import org.apache.ignite.internal.util.direct.*; +import org.apache.ignite.internal.util.typedef.internal.*; + +import java.nio.*; +import java.util.*; + +/** + * Client message wrapper for direct marshalling. + */ +public class GridClientMessageWrapper extends GridTcpCommunicationMessageAdapter { + /** */ + private static final long serialVersionUID = 5284375300887454697L; + + /** Client request header. */ + public static final byte REQ_HEADER = (byte)0x90; + + /** */ + private int msgSize; + + /** */ + private long reqId; + + /** */ + private UUID clientId; + + /** */ + private UUID destId; + + /** */ + private ByteBuffer msg; + + /** + * @return Request ID. + */ + public long requestId() { + return reqId; + } + + /** + * @param reqId Request ID. + */ + public void requestId(long reqId) { + this.reqId = reqId; + } + + /** + * @return Message size. + */ + public int messageSize() { + return msgSize; + } + + /** + * @param msgSize Message size. + */ + public void messageSize(int msgSize) { + this.msgSize = msgSize; + } + + /** + * @return Client ID. + */ + public UUID clientId() { + return clientId; + } + + /** + * @param clientId Client ID. + */ + public void clientId(UUID clientId) { + this.clientId = clientId; + } + + /** + * @return Destination ID. + */ + public UUID destinationId() { + return destId; + } + + /** + * @param destId Destination ID. + */ + public void destinationId(UUID destId) { + this.destId = destId; + } + + /** + * @return Message buffer. + */ + public ByteBuffer message() { + return msg; + } + + /** + * @return Message bytes. + */ + public byte[] messageArray() { + assert msg.hasArray(); + assert msg.position() == 0 && msg.remaining() == msg.capacity(); + + return msg.array(); + } + + /** + * @param msg Message bytes. + */ + public void message(ByteBuffer msg) { + this.msg = msg; + } + + /** {@inheritDoc} */ + @Override public boolean writeTo(ByteBuffer buf) { + commState.setBuffer(buf); + + if (!commState.typeWritten) { + if (!commState.putByte(directType())) + return false; + + commState.typeWritten = true; + } + + switch (commState.idx) { + case 0: + if (!commState.putIntClient(msgSize)) + return false; + + commState.idx++; + + case 1: + if (!commState.putLongClient(reqId)) + return false; + + commState.idx++; + + case 2: + if (!commState.putUuidClient(clientId)) + return false; + + commState.idx++; + + case 3: + if (!commState.putUuidClient(destId)) + return false; + + commState.idx++; + + case 4: + if (!commState.putByteBufferClient(msg)) + return false; + + commState.idx++; + + } + + return true; + } + + /** {@inheritDoc} */ + @Override public boolean readFrom(ByteBuffer buf) { + commState.setBuffer(buf); + + switch (commState.idx) { + case 0: + if (buf.remaining() < 4) + return false; + + msgSize = commState.getIntClient(); + + if (msgSize == 0) // Ping message. + return true; + + commState.idx++; + + case 1: + if (buf.remaining() < 8) + return false; + + reqId = commState.getLongClient(); + + commState.idx++; + + case 2: + UUID clientId0 = commState.getUuidClient(); + + if (clientId0 == UUID_NOT_READ) + return false; + + clientId = clientId0; + + commState.idx++; + + case 3: + UUID destId0 = commState.getUuidClient(); + + if (destId0 == UUID_NOT_READ) + return false; + + destId = destId0; + + commState.idx++; + + case 4: + byte[] msg0 = commState.getByteArrayClient(msgSize - 40); + + if (msg0 == BYTE_ARR_NOT_READ) + return false; + + msg = ByteBuffer.wrap(msg0); + + commState.idx++; + } + + return true; + } + + /** {@inheritDoc} */ + @Override public byte directType() { + return REQ_HEADER; + } + + /** {@inheritDoc} */ + @SuppressWarnings({"CloneDoesntCallSuperClone", "CloneCallsConstructors"}) + @Override public GridTcpCommunicationMessageAdapter clone() { + GridClientMessageWrapper _clone = new GridClientMessageWrapper(); + + clone0(_clone); + + return _clone; + } + + /** {@inheritDoc} */ + @Override protected void clone0(GridTcpCommunicationMessageAdapter _msg) { + GridClientMessageWrapper _clone = (GridClientMessageWrapper)_msg; + + _clone.reqId = reqId; + _clone.msgSize = msgSize; + _clone.clientId = clientId; + _clone.destId = destId; + _clone.msg = msg; + } + + /** {@inheritDoc} */ + @Override public String toString() { + return S.toString(GridClientMessageWrapper.class, this); + } +}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1b0e45a2/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientMetaDataResponse.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientMetaDataResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientMetaDataResponse.java new file mode 100644 index 0000000..86855a2 --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientMetaDataResponse.java @@ -0,0 +1,57 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal.processors.rest.client.message; + +import org.apache.ignite.portables.*; +import org.apache.ignite.internal.util.typedef.internal.*; + +import java.util.*; + +/** + * Metadata response. + */ +public class GridClientMetaDataResponse implements PortableMarshalAware { + /** */ + private Map<Integer, PortableMetadata> meta; + + /** + * @param meta Portable objects metadata. + */ + public void metaData(Map<Integer, PortableMetadata> meta) { + this.meta = meta; + } + + /** {@inheritDoc} */ + @Override public void writePortable(PortableWriter writer) throws PortableException { + PortableRawWriter raw = writer.rawWriter(); + + raw.writeMap(meta); + } + + /** {@inheritDoc} */ + @Override public void readPortable(PortableReader reader) throws PortableException { + PortableRawReader raw = reader.rawReader(); + + meta = raw.readMap(); + } + + /** {@inheritDoc} */ + @Override public String toString() { + return S.toString(GridClientMetaDataResponse.class, this); + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1b0e45a2/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientNodeBean.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientNodeBean.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientNodeBean.java new file mode 100644 index 0000000..774c163 --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientNodeBean.java @@ -0,0 +1,342 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal.processors.rest.client.message; + +import org.apache.ignite.portables.*; +import org.apache.ignite.internal.util.typedef.internal.*; + +import java.io.*; +import java.util.*; + +/** + * Node bean. + */ +public class GridClientNodeBean implements Externalizable, PortableMarshalAware { + /** */ + private static final long serialVersionUID = 0L; + + /** Node ID */ + private UUID nodeId; + + /** Consistent ID. */ + private Object consistentId; + + /** REST TCP server addresses. */ + private Collection<String> tcpAddrs; + + /** REST TCP server host names. */ + private Collection<String> tcpHostNames; + + /** Rest binary port. */ + private int tcpPort; + + /** Metrics. */ + private GridClientNodeMetricsBean metrics; + + /** Node attributes. */ + private Map<String, Object> attrs; + + /** Mode for cache with {@code null} name. */ + private String dfltCacheMode; + + /** Node caches. */ + private Map<String, String> caches; + + /** Default replica count for partitioned cache. */ + private int replicaCnt; + + /** + * Gets node ID. + * + * @return Node Id. + */ + public UUID getNodeId() { + return nodeId; + } + + /** + * Sets node ID. + * + * @param nodeId Node ID. + */ + public void setNodeId(UUID nodeId) { + this.nodeId = nodeId; + } + + /** + * @return Consistent ID. + */ + public Object getConsistentId() { + return consistentId; + } + + /** + * @param consistentId New consistent ID. + */ + public void setConsistentId(Object consistentId) { + this.consistentId = consistentId; + } + + /** + * Gets REST TCP server addresses. + * + * @return REST TCP server addresses. + */ + public Collection<String> getTcpAddresses() { + return tcpAddrs; + } + + /** + * Gets REST TCP server host names. + * + * @return REST TCP server host names. + */ + public Collection<String> getTcpHostNames() { + return tcpHostNames; + } + + /** + * Sets REST TCP server addresses. + * + * @param tcpAddrs REST TCP server addresses. + */ + public void setTcpAddresses(Collection<String> tcpAddrs) { + this.tcpAddrs = tcpAddrs; + } + + /** + * Sets REST TCP server host names. + * + * @param tcpHostNames REST TCP server host names. + */ + public void setTcpHostNames(Collection<String> tcpHostNames) { + this.tcpHostNames = tcpHostNames; + } + + /** + * Gets metrics. + * + * @return Metrics. + */ + public GridClientNodeMetricsBean getMetrics() { + return metrics; + } + + /** + * Sets metrics. + * + * @param metrics Metrics. + */ + public void setMetrics(GridClientNodeMetricsBean metrics) { + this.metrics = metrics; + } + + /** + * Gets attributes. + * + * @return Attributes. + */ + public Map<String, Object> getAttributes() { + return attrs; + } + + /** + * Sets attributes. + * + * @param attrs Attributes. + */ + public void setAttributes(Map<String, Object> attrs) { + this.attrs = attrs; + } + + /** + * Gets REST binary protocol port. + * + * @return Port on which REST binary protocol is bound. + */ + public int getTcpPort() { + return tcpPort; + } + + /** + * Gets configured node caches. + * + * @return Map where key is cache name and value is cache mode ("LOCAL", "REPLICATED", "PARTITIONED"). + */ + public Map<String, String> getCaches() { + return caches; + } + + /** + * Sets configured node caches. + * + * @param caches Map where key is cache name and value is cache mode ("LOCAL", "REPLICATED", "PARTITIONED"). + */ + public void setCaches(Map<String, String> caches) { + this.caches = caches; + } + + /** + * Gets mode for cache with null name. + * + * @return Default cache mode. + */ + public String getDefaultCacheMode() { + return dfltCacheMode; + } + + /** + * Sets mode for default cache. + * + * @param dfltCacheMode Default cache mode. + */ + public void setDefaultCacheMode(String dfltCacheMode) { + this.dfltCacheMode = dfltCacheMode; + } + + /** + * Gets node replica count on consistent hash ring. + * + * @return Node replica count. + */ + public int getReplicaCount() { + return replicaCnt; + } + + /** + * Sets node replica count on consistent hash ring. + * + * @param replicaCnt Node replica count. + */ + public void setReplicaCount(int replicaCnt) { + this.replicaCnt = replicaCnt; + } + + /** + * Sets REST binary protocol port. + * + * @param tcpPort Port on which REST binary protocol is bound. + */ + public void setTcpPort(int tcpPort) { + this.tcpPort = tcpPort; + } + + /** {@inheritDoc} */ + @Override public int hashCode() { + return nodeId != null ? nodeId.hashCode() : 0; + } + + /** {@inheritDoc} */ + @Override public boolean equals(Object obj) { + if (this == obj) + return true; + + if (obj == null || getClass() != obj.getClass()) + return false; + + GridClientNodeBean other = (GridClientNodeBean)obj; + + return nodeId == null ? other.nodeId == null : nodeId.equals(other.nodeId); + } + + /** {@inheritDoc} */ + @Override public void writePortable(PortableWriter writer) throws PortableException { + PortableRawWriter raw = writer.rawWriter(); + + raw.writeInt(tcpPort); + raw.writeInt(replicaCnt); + raw.writeString(dfltCacheMode); + raw.writeMap(attrs); + raw.writeMap(caches); + raw.writeCollection(tcpAddrs); + raw.writeCollection(tcpHostNames); + raw.writeUuid(nodeId); + raw.writeObject(consistentId); + raw.writeObject(metrics); + } + + /** {@inheritDoc} */ + @Override public void readPortable(PortableReader reader) throws PortableException { + PortableRawReader raw = reader.rawReader(); + + tcpPort = raw.readInt(); + replicaCnt = raw.readInt(); + + dfltCacheMode = raw.readString(); + + attrs = raw.readMap(); + caches = raw.readMap(); + + tcpAddrs = raw.readCollection(); + tcpHostNames = raw.readCollection(); + + nodeId = raw.readUuid(); + + consistentId = raw.readObject(); + metrics = (GridClientNodeMetricsBean)raw.readObject(); + } + + /** {@inheritDoc} */ + @Override public void writeExternal(ObjectOutput out) throws IOException { + out.writeInt(tcpPort); + out.writeInt(0); // Jetty port. + out.writeInt(replicaCnt); + + U.writeString(out, dfltCacheMode); + + U.writeMap(out, attrs); + U.writeMap(out, caches); + + U.writeCollection(out, tcpAddrs); + U.writeCollection(out, tcpHostNames); + U.writeCollection(out, Collections.emptyList()); // Jetty addresses. + U.writeCollection(out, Collections.emptyList()); // Jetty host names. + + U.writeUuid(out, nodeId); + + out.writeObject(consistentId); + out.writeObject(metrics); + } + + /** {@inheritDoc} */ + @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { + tcpPort = in.readInt(); + in.readInt(); // Jetty port. + replicaCnt = in.readInt(); + + dfltCacheMode = U.readString(in); + + attrs = U.readMap(in); + caches = U.readMap(in); + + tcpAddrs = U.readCollection(in); + tcpHostNames = U.readCollection(in); + U.readCollection(in); // Jetty addresses. + U.readCollection(in); // Jetty host names. + + nodeId = U.readUuid(in); + + consistentId = in.readObject(); + metrics = (GridClientNodeMetricsBean)in.readObject(); + } + + /** {@inheritDoc} */ + @Override public String toString() { + return "GridClientNodeBean [id=" + nodeId + ']'; + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1b0e45a2/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientNodeMetricsBean.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientNodeMetricsBean.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientNodeMetricsBean.java new file mode 100644 index 0000000..98a499a --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientNodeMetricsBean.java @@ -0,0 +1,1578 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal.processors.rest.client.message; + +import org.apache.ignite.portables.*; + +import java.io.*; + +/** + * Node metrics bean. + */ +public class GridClientNodeMetricsBean implements Externalizable, PortableMarshalAware { + /** */ + private static final long serialVersionUID = 0L; + + /** */ + private long lastUpdateTime = -1; + + /** */ + private int maxActiveJobs = -1; + + /** */ + private int curActiveJobs = -1; + + /** */ + private float avgActiveJobs = -1; + + /** */ + private int maxWaitingJobs = -1; + + /** */ + private int curWaitingJobs = -1; + + /** */ + private float avgWaitingJobs = -1; + + /** */ + private int maxRejectedJobs = -1; + + /** */ + private int curRejectedJobs = -1; + + /** */ + private float avgRejectedJobs = -1; + + /** */ + private int maxCancelledJobs = -1; + + /** */ + private int curCancelledJobs = -1; + + /** */ + private float avgCancelledJobs = -1; + + /** */ + private int totalRejectedJobs = -1; + + /** */ + private int totalCancelledJobs = -1; + + /** */ + private int totalExecutedJobs = -1; + + /** */ + private long maxJobWaitTime = -1; + + /** */ + private long curJobWaitTime = -1; + + /** */ + private double avgJobWaitTime = -1; + + /** */ + private long maxJobExecTime = -1; + + /** */ + private long curJobExecTime = -1; + + /** */ + private double avgJobExecTime = -1; + + /** */ + private int totalExecTasks = -1; + + /** */ + private long totalIdleTime = -1; + + /** */ + private long curIdleTime = -1; + + /** */ + private int availProcs = -1; + + /** */ + private double load = -1; + + /** */ + private double avgLoad = -1; + + /** */ + private double gcLoad = -1; + + /** */ + private long heapInit = -1; + + /** */ + private long heapUsed = -1; + + /** */ + private long heapCommitted = -1; + + /** */ + private long heapMax = -1; + + /** */ + private long nonHeapInit = -1; + + /** */ + private long nonHeapUsed = -1; + + /** */ + private long nonHeapCommitted = -1; + + /** */ + private long nonHeapMax = -1; + + /** */ + private long upTime = -1; + + /** */ + private long startTime = -1; + + /** */ + private long nodeStartTime = -1; + + /** */ + private int threadCnt = -1; + + /** */ + private int peakThreadCnt = -1; + + /** */ + private long startedThreadCnt = -1; + + /** */ + private int daemonThreadCnt = -1; + + /** */ + private long fileSysFreeSpace = -1; + + /** */ + private long fileSysTotalSpace = -1; + + /** */ + private long fileSysUsableSpace = -1; + + /** */ + private long lastDataVer = -1; + + /** */ + private int sentMsgsCnt = -1; + + /** */ + private long sentBytesCnt = -1; + + /** */ + private int rcvdMsgsCnt = -1; + + /** */ + private long rcvdBytesCnt = -1; + + /** + * Gets last update time. + * + * @return Last update time. + */ + public long getLastUpdateTime() { + return lastUpdateTime; + } + + /** + * Sets last update time. + * + * @param lastUpdateTime Last update time. + */ + public void setLastUpdateTime(long lastUpdateTime) { + this.lastUpdateTime = lastUpdateTime; + } + + /** + * Gets max active jobs. + * + * @return Max active jobs. + */ + public int getMaximumActiveJobs() { + return maxActiveJobs; + } + + /** + * Sets max active jobs. + * + * @param maxActiveJobs Max active jobs. + */ + public void setMaximumActiveJobs(int maxActiveJobs) { + this.maxActiveJobs = maxActiveJobs; + } + + /** + * Gets current active jobs. + * + * @return Current active jobs. + */ + public int getCurrentActiveJobs() { + return curActiveJobs; + } + + /** + * Sets current active jobs. + * + * @param curActiveJobs Current active jobs. + */ + public void setCurrentActiveJobs(int curActiveJobs) { + this.curActiveJobs = curActiveJobs; + } + + /** + * Gets average active jobs. + * + * @return Average active jobs. + */ + public float getAverageActiveJobs() { + return avgActiveJobs; + } + + /** + * Sets average active jobs. + * + * @param avgActiveJobs Average active jobs. + */ + public void setAverageActiveJobs(float avgActiveJobs) { + this.avgActiveJobs = avgActiveJobs; + } + + /** + * Gets maximum waiting jobs. + * + * @return Maximum active jobs. + */ + public int getMaximumWaitingJobs() { + return maxWaitingJobs; + } + + /** + * Sets maximum waiting jobs. + * + * @param maxWaitingJobs Maximum waiting jobs. + */ + public void setMaximumWaitingJobs(int maxWaitingJobs) { + this.maxWaitingJobs = maxWaitingJobs; + } + + /** + * Gets current waiting jobs. + * + * @return Current waiting jobs. + */ + public int getCurrentWaitingJobs() { + return curWaitingJobs; + } + + /** + * Sets current waiting jobs. + * + * @param curWaitingJobs Current waiting jobs. + */ + public void setCurrentWaitingJobs(int curWaitingJobs) { + this.curWaitingJobs = curWaitingJobs; + } + + /** + * Gets average waiting jobs. + * + * @return Average waiting jobs. + */ + public float getAverageWaitingJobs() { + return avgWaitingJobs; + } + + /** + * Sets average waiting jobs. + * + * @param avgWaitingJobs Average waiting jobs. + */ + public void setAverageWaitingJobs(float avgWaitingJobs) { + this.avgWaitingJobs = avgWaitingJobs; + } + + /** + * @return Maximum number of jobs rejected during a single collision resolution event. + */ + public int getMaximumRejectedJobs() { + return maxRejectedJobs; + } + + /** + * @param maxRejectedJobs Maximum number of jobs rejected during a single collision resolution event. + */ + public void setMaximumRejectedJobs(int maxRejectedJobs) { + this.maxRejectedJobs = maxRejectedJobs; + } + + /** + * @return Number of jobs rejected during most recent collision resolution. + */ + public int getCurrentRejectedJobs() { + return curRejectedJobs; + } + + /** + * @param curRejectedJobs Number of jobs rejected during most recent collision resolution. + */ + public void setCurrentRejectedJobs(int curRejectedJobs) { + this.curRejectedJobs = curRejectedJobs; + } + + /** + * @return Average number of jobs this node rejects. + */ + public float getAverageRejectedJobs() { + return avgRejectedJobs; + } + + /** + * @param avgRejectedJobs Average number of jobs this node rejects. + */ + public void setAverageRejectedJobs(float avgRejectedJobs) { + this.avgRejectedJobs = avgRejectedJobs; + } + + /** + * @return Total number of jobs this node ever rejected. + */ + public int getTotalRejectedJobs() { + return totalRejectedJobs; + } + + /** + * @param totalRejectedJobs Total number of jobs this node ever rejected. + */ + public void setTotalRejectedJobs(int totalRejectedJobs) { + this.totalRejectedJobs = totalRejectedJobs; + } + + /** + * Gets maximum cancelled jobs. + * + * @return Maximum cancelled jobs. + */ + public int getMaximumCancelledJobs() { + return maxCancelledJobs; + } + + /** + * Sets maximum cancelled jobs. + * + * @param maxCancelledJobs Maximum cancelled jobs. + */ + public void setMaximumCancelledJobs(int maxCancelledJobs) { + this.maxCancelledJobs = maxCancelledJobs; + } + + /** + * Gets current cancelled jobs. + * + * @return Current cancelled jobs. + */ + public int getCurrentCancelledJobs() { + return curCancelledJobs; + } + + /** + * Sets current cancelled jobs. + * + * @param curCancelledJobs Current cancelled jobs. + */ + public void setCurrentCancelledJobs(int curCancelledJobs) { + this.curCancelledJobs = curCancelledJobs; + } + + /** + * Gets average cancelled jobs. + * + * @return Average cancelled jobs. + */ + public float getAverageCancelledJobs() { + return avgCancelledJobs; + } + + /** + * Sets average cancelled jobs. + * + * @param avgCancelledJobs Average cancelled jobs. + */ + public void setAverageCancelledJobs(float avgCancelledJobs) { + this.avgCancelledJobs = avgCancelledJobs; + } + + /** + * Gets total active jobs. + * + * @return Total active jobs. + */ + public int getTotalExecutedJobs() { + return totalExecutedJobs; + } + + /** + * Sets total active jobs. + * + * @param totalExecutedJobs Total active jobs. + */ + public void setTotalExecutedJobs(int totalExecutedJobs) { + this.totalExecutedJobs = totalExecutedJobs; + } + + /** + * Gets total cancelled jobs. + * + * @return Total cancelled jobs. + */ + public int getTotalCancelledJobs() { + return totalCancelledJobs; + } + + /** + * Sets total cancelled jobs. + * + * @param totalCancelledJobs Total cancelled jobs. + */ + public void setTotalCancelledJobs(int totalCancelledJobs) { + this.totalCancelledJobs = totalCancelledJobs; + } + + /** + * Gets max job wait time. + * + * @return Max job wait time. + */ + public long getMaximumJobWaitTime() { + return maxJobWaitTime; + } + + /** + * Sets max job wait time. + * + * @param maxJobWaitTime Max job wait time. + */ + public void setMaximumJobWaitTime(long maxJobWaitTime) { + this.maxJobWaitTime = maxJobWaitTime; + } + + /** + * Gets current job wait time. + * + * @return Current job wait time. + */ + public long getCurrentJobWaitTime() { + return curJobWaitTime; + } + + /** + * Sets current job wait time. + * + * @param curJobWaitTime Current job wait time. + */ + public void setCurrentJobWaitTime(long curJobWaitTime) { + this.curJobWaitTime = curJobWaitTime; + } + + /** + * Gets average job wait time. + * + * @return Average job wait time. + */ + public double getAverageJobWaitTime() { + return avgJobWaitTime; + } + + /** + * Sets average job wait time. + * + * @param avgJobWaitTime Average job wait time. + */ + public void setAverageJobWaitTime(double avgJobWaitTime) { + this.avgJobWaitTime = avgJobWaitTime; + } + + /** + * Gets maximum job execution time. + * + * @return Maximum job execution time. + */ + public long getMaximumJobExecuteTime() { + return maxJobExecTime; + } + + /** + * Sets maximum job execution time. + * + * @param maxJobExecTime Maximum job execution time. + */ + public void setMaximumJobExecuteTime(long maxJobExecTime) { + this.maxJobExecTime = maxJobExecTime; + } + + /** + * Gets current job execute time. + * + * @return Current job execute time. + */ + public long getCurrentJobExecuteTime() { + return curJobExecTime; + } + + /** + * Sets current job execute time. + * + * @param curJobExecTime Current job execute time. + */ + public void setCurrentJobExecuteTime(long curJobExecTime) { + this.curJobExecTime = curJobExecTime; + } + + /** + * Gets average job execution time. + * + * @return Average job execution time. + */ + public double getAverageJobExecuteTime() { + return avgJobExecTime; + } + + /** + * Sets average job execution time. + * + * @param avgJobExecTime Average job execution time. + */ + public void setAverageJobExecuteTime(double avgJobExecTime) { + this.avgJobExecTime = avgJobExecTime; + } + + /** + * Gets total number of tasks handled by the node. + * + * @return Total number of tasks handled by the node. + */ + public int getTotalExecutedTasks() { + return totalExecTasks; + } + + /** + * Sets total number of tasks handled by the node. + * + * @param totalExecTasks Total number of tasks handled by the node. + */ + public void setTotalExecutedTasks(int totalExecTasks) { + this.totalExecTasks = totalExecTasks; + } + + /** + * @return Total busy time. + */ + public long getTotalBusyTime() { + return getUpTime() - getTotalIdleTime(); + } + + /** + * @return Total idle time. + */ + public long getTotalIdleTime() { + return totalIdleTime; + } + + /** + * Set total node idle time. + * + * @param totalIdleTime Total node idle time. + */ + public void setTotalIdleTime(long totalIdleTime) { + this.totalIdleTime = totalIdleTime; + } + + /** + * @return Current idle time. + */ + public long getCurrentIdleTime() { + return curIdleTime; + } + + /** + * Sets time elapsed since execution of last job. + * + * @param curIdleTime Time elapsed since execution of last job. + */ + public void setCurrentIdleTime(long curIdleTime) { + this.curIdleTime = curIdleTime; + } + + /** + * Gets percentage of time this node is busy executing jobs vs. idling. + * + * @return Percentage of time this node is busy (value is less than + * or equal to {@code 1} and greater than or equal to {@code 0}) + */ + public float getBusyTimePercentage() { + return 1 - getIdleTimePercentage(); + } + + /** + * Gets percentage of time this node is idling vs. executing jobs. + * + * @return Percentage of time this node is idle (value is less than + * or equal to {@code 1} and greater than or equal to {@code 0}) + */ + public float getIdleTimePercentage() { + return getTotalIdleTime() / (float)getUpTime(); + } + + /** + * Returns the number of CPUs available to the Java Virtual Machine. + * This method is equivalent to the {@link Runtime#availableProcessors()} + * method. + * <p> + * Note that this value may change during successive invocations of the + * virtual machine. + * + * @return The number of processors available to the virtual + * machine, never smaller than one. + */ + public int getTotalCpus() { + return availProcs; + } + + /** + * Returns the system load average for the last minute. + * The system load average is the sum of the number of runnable entities + * queued to the {@linkplain #getTotalCpus available processors} + * and the number of runnable entities running on the available processors + * averaged over a period of time. + * The way in which the load average is calculated is operating system + * specific but is typically a damped time-dependent average. + * <p> + * If the load average is not available, a negative value is returned. + * <p> + * This method is designed to provide a hint about the system load + * and may be queried frequently. The load average may be unavailable on + * some platform where it is expensive to implement this method. + * + * @return The system load average in {@code [0, 1]} range. + * Negative value if not available. + */ + public double getCurrentCpuLoad() { + return load; + } + + /** + * Gets average of CPU load values over all metrics kept in the history. + * + * @return Average of CPU load value in {@code [0, 1]} range over all metrics kept + * in the history. + */ + public double getAverageCpuLoad() { + return avgLoad; + } + + /** + * Returns average CPU spent for CG since the last update. + * + * @return Average CPU spent for CG since the last update. + */ + public double getCurrentGcCpuLoad() { + return gcLoad; + } + + /** + * Returns the amount of heap memory in bytes that the Java virtual machine + * initially requests from the operating system for memory management. + * This method returns {@code -1} if the initial memory size is undefined. + * + * @return The initial size of memory in bytes; {@code -1} if undefined. + */ + public long getHeapMemoryInitialized() { + return heapInit; + } + + /** + * Returns the current heap size that is used for object allocation. + * The heap consists of one or more memory pools. This value is + * the sum of {@code used} heap memory values of all heap memory pools. + * <p> + * The amount of used memory in the returned is the amount of memory + * occupied by both live objects and garbage objects that have not + * been collected, if any. + * <p> + * <b>Note:</b> this is <b>not</b> an aggregated metric and it's calculated + * from the time of the node's startup. + * + * @return Amount of heap memory used. + */ + public long getHeapMemoryUsed() { + return heapUsed; + } + + /** + * Returns the amount of heap memory in bytes that is committed for + * the Java virtual machine to use. This amount of memory is + * guaranteed for the Java virtual machine to use. + * The heap consists of one or more memory pools. This value is + * the sum of {@code committed} heap memory values of all heap memory pools. + * <p> + * <b>Note:</b> this is <b>not</b> an aggregated metric and it's calculated + * from the time of the node's startup. + * + * @return The amount of committed memory in bytes. + */ + public long getHeapMemoryCommitted() { + return heapCommitted; + } + + /** + * Returns the maximum amount of heap memory in bytes that can be + * used for memory management. This method returns {@code -1} + * if the maximum memory size is undefined. + * <p> + * This amount of memory is not guaranteed to be available + * for memory management if it is greater than the amount of + * committed memory. The Java virtual machine may fail to allocate + * memory even if the amount of used memory does not exceed this + * maximum size. + * <p> + * This value represents a setting of the heap memory for Java VM and is + * not a sum of all initial heap values for all memory pools. + * <p> + * <b>Note:</b> this is <b>not</b> an aggregated metric and it's calculated + * from the time of the node's startup. + * + * @return The maximum amount of memory in bytes; {@code -1} if undefined. + */ + public long getHeapMemoryMaximum() { + return heapMax; + } + + /** + * Returns the amount of non-heap memory in bytes that the Java virtual machine + * initially requests from the operating system for memory management. + * This method returns {@code -1} if the initial memory size is undefined. + * <p> + * This value represents a setting of non-heap memory for Java VM and is + * not a sum of all initial heap values for all memory pools. + * <p> + * <b>Note:</b> this is <b>not</b> an aggregated metric and it's calculated + * from the time of the node's startup. + * + * @return The initial size of memory in bytes; {@code -1} if undefined. + */ + public long getNonHeapMemoryInitialized() { + return nonHeapInit; + } + + /** + * Returns the current non-heap memory size that is used by Java VM. + * The non-heap memory consists of one or more memory pools. This value is + * the sum of {@code used} non-heap memory values of all non-heap memory pools. + * <p> + * <b>Note:</b> this is <b>not</b> an aggregated metric and it's calculated + * from the time of the node's startup. + * <p> + * <b>Note:</b> this is <b>not</b> an aggregated metric and it's calculated + * from the time of the node's startup. + * + * @return Amount of none-heap memory used. + */ + public long getNonHeapMemoryUsed() { + return nonHeapUsed; + } + + /** + * Returns the amount of non-heap memory in bytes that is committed for + * the Java virtual machine to use. This amount of memory is + * guaranteed for the Java virtual machine to use. + * The non-heap memory consists of one or more memory pools. This value is + * the sum of {@code committed} non-heap memory values of all non-heap memory pools. + * <p> + * <b>Note:</b> this is <b>not</b> an aggregated metric and it's calculated + * from the time of the node's startup. + * + * @return The amount of committed memory in bytes. + */ + public long getNonHeapMemoryCommitted() { + return nonHeapCommitted; + } + + /** + * Returns the maximum amount of non-heap memory in bytes that can be + * used for memory management. This method returns {@code -1} + * if the maximum memory size is undefined. + * <p> + * This amount of memory is not guaranteed to be available + * for memory management if it is greater than the amount of + * committed memory. The Java virtual machine may fail to allocate + * memory even if the amount of used memory does not exceed this + * maximum size. + * <p> + * This value represents a setting of the non-heap memory for Java VM and is + * not a sum of all initial non-heap values for all memory pools. + * <p> + * <b>Note:</b> this is <b>not</b> an aggregated metric and it's calculated + * from the time of the node's startup. + * + * @return The maximum amount of memory in bytes; {@code -1} if undefined. + */ + public long getNonHeapMemoryMaximum() { + return nonHeapMax; + } + + /** + * Returns the uptime of the Java virtual machine in milliseconds. + * + * @return Uptime of the Java virtual machine in milliseconds. + */ + public long getUpTime() { + return upTime; + } + + /** + * Returns the start time of the Java virtual machine in milliseconds. + * This method returns the approximate time when the Java virtual + * machine started. + * + * @return Start time of the Java virtual machine in milliseconds. + */ + public long getStartTime() { + return startTime; + } + + /** + * Returns the start time of grid node in milliseconds. + * There can be several grid nodes started in one JVM, so JVM start time will be + * the same for all of them, but node start time will be different. + * + * @return Start time of the grid node in milliseconds. + */ + public long getNodeStartTime() { + return nodeStartTime; + } + + /** + * Returns the current number of live threads including both + * daemon and non-daemon threads. + * + * @return Current number of live threads. + */ + public int getCurrentThreadCount() { + return threadCnt; + } + + /** + * Returns the maximum live thread count since the Java virtual machine + * started or peak was reset. + * <p> + * <b>Note:</b> this is <b>not</b> an aggregated metric and it's calculated + * from the time of the node's startup. + * + * @return The peak live thread count. + */ + public int getMaximumThreadCount() { + return peakThreadCnt; + } + + /** + * Returns the total number of threads created and also started + * since the Java virtual machine started. + * <p> + * <b>Note:</b> this is <b>not</b> an aggregated metric and it's calculated + * from the time of the node's startup. + * + * @return The total number of threads started. + */ + public long getTotalStartedThreadCount() { + return startedThreadCnt; + } + + /** + * Returns the current number of live daemon threads. + * + * @return Current number of live daemon threads. + */ + public int getCurrentDaemonThreadCount() { + return daemonThreadCnt; + } + + /** + * Returns the number of unallocated bytes in the partition. + * + * @return Number of unallocated bytes in the partition. + */ + public long getFileSystemFreeSpace() { + return fileSysFreeSpace; + } + + /** + * Returns the size of the partition. + * + * @return Size of the partition. + */ + public long getFileSystemTotalSpace() { + return fileSysTotalSpace; + } + + /** + * Returns the number of bytes available to this virtual machine on the partition. + * + * @return Number of bytes available to this virtual machine on the partition. + */ + public long getFileSystemUsableSpace() { + return fileSysUsableSpace; + } + + /** + * In-memory data grid assigns incremental versions to all cache operations. This method provides + * the latest data version on the node. + * + * @return Last data version. + */ + public long getLastDataVersion() { + return lastDataVer; + } + + /** + * Sets available processors. + * + * @param availProcs Available processors. + */ + public void setTotalCpus(int availProcs) { + this.availProcs = availProcs; + } + + /** + * Sets current CPU load. + * + * @param load Current CPU load. + */ + public void setCurrentCpuLoad(double load) { + this.load = load; + } + + /** + * Sets CPU load average over the metrics history. + * + * @param avgLoad CPU load average. + */ + public void setAverageCpuLoad(double avgLoad) { + this.avgLoad = avgLoad; + } + + /** + * Sets current GC CPU load. + * + * @param gcLoad Current GC load. + */ + public void setCurrentGcCpuLoad(double gcLoad) { + this.gcLoad = gcLoad; + } + + /** + * Sets heap initial memory. + * + * @param heapInit Heap initial memory. + */ + public void setHeapMemoryInitialized(long heapInit) { + this.heapInit = heapInit; + } + + /** + * Sets used heap memory. + * + * @param heapUsed Used heap memory. + */ + public void setHeapMemoryUsed(long heapUsed) { + this.heapUsed = heapUsed; + } + + /** + * Sets committed heap memory. + * + * @param heapCommitted Committed heap memory. + */ + public void setHeapMemoryCommitted(long heapCommitted) { + this.heapCommitted = heapCommitted; + } + + /** + * Sets maximum possible heap memory. + * + * @param heapMax Maximum possible heap memory. + */ + public void setHeapMemoryMaximum(long heapMax) { + this.heapMax = heapMax; + } + + /** + * Sets initial non-heap memory. + * + * @param nonHeapInit Initial non-heap memory. + */ + public void setNonHeapMemoryInitialized(long nonHeapInit) { + this.nonHeapInit = nonHeapInit; + } + + /** + * Sets used non-heap memory. + * + * @param nonHeapUsed Used non-heap memory. + */ + public void setNonHeapMemoryUsed(long nonHeapUsed) { + this.nonHeapUsed = nonHeapUsed; + } + + /** + * Sets committed non-heap memory. + * + * @param nonHeapCommitted Committed non-heap memory. + */ + public void setNonHeapMemoryCommitted(long nonHeapCommitted) { + this.nonHeapCommitted = nonHeapCommitted; + } + + /** + * Sets maximum possible non-heap memory. + * + * @param nonHeapMax Maximum possible non-heap memory. + */ + public void setNonHeapMemoryMaximum(long nonHeapMax) { + this.nonHeapMax = nonHeapMax; + } + + /** + * Sets VM up time. + * + * @param upTime VN up time. + */ + public void setUpTime(long upTime) { + this.upTime = upTime; + } + + /** + * Sets VM start time. + * + * @param startTime VM start time. + */ + public void setStartTime(long startTime) { + this.startTime = startTime; + } + + /** + * Sets node start time. + * + * @param nodeStartTime node start time. + */ + public void setNodeStartTime(long nodeStartTime) { + this.nodeStartTime = nodeStartTime; + } + + /** + * Sets thread count. + * + * @param threadCnt Thread count. + */ + public void setCurrentThreadCount(int threadCnt) { + this.threadCnt = threadCnt; + } + + /** + * Sets peak thread count. + * + * @param peakThreadCnt Peak thread count. + */ + public void setMaximumThreadCount(int peakThreadCnt) { + this.peakThreadCnt = peakThreadCnt; + } + + /** + * Sets started thread count. + * + * @param startedThreadCnt Started thread count. + */ + public void setTotalStartedThreadCount(long startedThreadCnt) { + this.startedThreadCnt = startedThreadCnt; + } + + /** + * Sets daemon thread count. + * + * @param daemonThreadCnt Daemon thread count. + */ + public void setCurrentDaemonThreadCount(int daemonThreadCnt) { + this.daemonThreadCnt = daemonThreadCnt; + } + + /** + * Sets the number of unallocated bytes in the partition. + * + * @param fileSysFreeSpace The number of unallocated bytes in the partition. + */ + public void setFileSystemFreeSpace(long fileSysFreeSpace) { + this.fileSysFreeSpace = fileSysFreeSpace; + } + + /** + * Sets size of the partition. + * + * @param fileSysTotalSpace Size of the partition. + */ + public void setFileSystemTotalSpace(long fileSysTotalSpace) { + this.fileSysTotalSpace = fileSysTotalSpace; + } + + /** + * Sets the number of bytes available to this virtual machine on the partition. + * + * @param fileSysUsableSpace The number of bytes available to + * this virtual machine on the partition. + */ + public void setFileSystemUsableSpace(long fileSysUsableSpace) { + this.fileSysUsableSpace = fileSysUsableSpace; + } + + /** + * @param lastDataVer Last data version. + */ + public void setLastDataVersion(long lastDataVer) { + this.lastDataVer = lastDataVer; + } + + /** + * Gets sent messages count. + * + * @return Sent messages count. + */ + public int getSentMessagesCount() { + return sentMsgsCnt; + } + + /** + * Sets sent messages count. + * + * @param sentMsgsCnt Sent messages count. + */ + public void setSentMessagesCount(int sentMsgsCnt) { + this.sentMsgsCnt = sentMsgsCnt; + } + + /** + * Gets sent bytes count. + * + * @return Sent bytes count. + */ + public long getSentBytesCount() { + return sentBytesCnt; + } + + /** + * Sets sent bytes count. + * + * @param sentBytesCnt Sent bytes count. + */ + public void setSentBytesCount(long sentBytesCnt) { + this.sentBytesCnt = sentBytesCnt; + } + + /** + * Gets received messages count. + * + * @return Received messages count. + */ + public int getReceivedMessagesCount() { + return rcvdMsgsCnt; + } + + /** + * Sets received messages count. + * + * @param rcvdMsgsCnt Received messages count. + */ + public void setReceivedMessagesCount(int rcvdMsgsCnt) { + this.rcvdMsgsCnt = rcvdMsgsCnt; + } + + /** + * Gets received bytes count. + * + * @return Received bytes count. + */ + public long getReceivedBytesCount() { + return rcvdBytesCnt; + } + + /** + * Sets received bytes count. + * + * @param rcvdBytesCnt Received bytes count. + */ + public void setReceivedBytesCount(long rcvdBytesCnt) { + this.rcvdBytesCnt = rcvdBytesCnt; + } + + /** {@inheritDoc} */ + public int hashCode() { + return System.identityHashCode(this); + } + + /** {@inheritDoc} */ + public boolean equals(Object obj) { + if (this == obj) + return true; + + if (obj == null || getClass() != obj.getClass()) + return false; + + GridClientNodeMetricsBean other = (GridClientNodeMetricsBean)obj; + + return availProcs == other.availProcs && + curActiveJobs == other.curActiveJobs && + curCancelledJobs == other.curCancelledJobs && + curIdleTime == other.curIdleTime && + curJobExecTime == other.curJobExecTime && + curJobWaitTime == other.curJobWaitTime && + curRejectedJobs == other.curRejectedJobs && + curWaitingJobs == other.curWaitingJobs && + daemonThreadCnt == other.daemonThreadCnt && + heapCommitted == other.heapCommitted && + heapInit == other.heapInit && + heapMax == other.heapMax && + heapUsed == other.heapUsed && + maxActiveJobs == other.maxActiveJobs && + maxCancelledJobs == other.maxCancelledJobs && + maxJobExecTime == other.maxJobExecTime && + maxJobWaitTime == other.maxJobWaitTime && + maxRejectedJobs == other.maxRejectedJobs && + maxWaitingJobs == other.maxWaitingJobs && + nonHeapCommitted == other.nonHeapCommitted && + nonHeapInit == other.nonHeapInit && + nonHeapMax == other.nonHeapMax && + nonHeapUsed == other.nonHeapUsed && + peakThreadCnt == other.peakThreadCnt && + startTime == other.startTime && + nodeStartTime == other.nodeStartTime && + startedThreadCnt == other.startedThreadCnt && + threadCnt == other.threadCnt && + totalCancelledJobs == other.totalCancelledJobs && + totalExecutedJobs == other.totalExecutedJobs && + totalIdleTime == other.totalIdleTime && + totalRejectedJobs == other.totalRejectedJobs && + fileSysFreeSpace == other.fileSysFreeSpace && + fileSysTotalSpace == other.fileSysTotalSpace && + fileSysUsableSpace == other.fileSysUsableSpace && + totalExecTasks == other.totalExecTasks && + sentMsgsCnt == other.sentMsgsCnt && + sentBytesCnt == other.sentBytesCnt && + rcvdMsgsCnt == other.rcvdMsgsCnt && + rcvdBytesCnt == other.rcvdBytesCnt && + upTime == other.upTime; + } + + /** {@inheritDoc} */ + @SuppressWarnings("StringBufferReplaceableByString") + @Override public String toString() { + return new StringBuilder(). + append("GridClientNodeMetricsBean [lastUpdateTime="). + append(lastUpdateTime). + append(", maxActiveJobs=").append(maxActiveJobs). + append(", curActiveJobs=").append(curActiveJobs). + append(", avgActiveJobs=").append(avgActiveJobs). + append(", maxWaitingJobs=").append(maxWaitingJobs). + append(", curWaitingJobs=").append(curWaitingJobs). + append(", avgWaitingJobs=").append(avgWaitingJobs). + append(", maxRejectedJobs=").append(maxRejectedJobs). + append(", curRejectedJobs=").append(curRejectedJobs). + append(", avgRejectedJobs=").append(avgRejectedJobs). + append(", maxCancelledJobs=").append(maxCancelledJobs). + append(", curCancelledJobs=").append(curCancelledJobs). + append(", avgCancelledJobs=").append(avgCancelledJobs). + append(", totalRejectedJobs=").append(totalRejectedJobs). + append(", totalCancelledJobs=").append(totalCancelledJobs). + append(", totalExecutedJobs=").append(totalExecutedJobs). + append(", maxJobWaitTime=").append(maxJobWaitTime). + append(", curJobWaitTime=").append(curJobWaitTime). + append(", avgJobWaitTime=").append(avgJobWaitTime). + append(", maxJobExecTime=").append(maxJobExecTime). + append(", curJobExecTime=").append(curJobExecTime). + append(", avgJobExecTime=").append(avgJobExecTime). + append(", totalExecTasks=").append(totalExecTasks). + append(", totalIdleTime=").append(totalIdleTime). + append(", curIdleTime=").append(curIdleTime). + append(", availProcs=").append(availProcs). + append(", load=").append(load). + append(", avgLoad=").append(avgLoad). + append(", gcLoad=").append(gcLoad). + append(", heapInit=").append(heapInit). + append(", heapUsed=").append(heapUsed). + append(", heapCommitted=").append(heapCommitted). + append(", heapMax=").append(heapMax). + append(", nonHeapInit=").append(nonHeapInit). + append(", nonHeapUsed=").append(nonHeapUsed). + append(", nonHeapCommitted=").append(nonHeapCommitted). + append(", nonHeapMax=").append(nonHeapMax). + append(", upTime=").append(upTime). + append(", startTime=").append(startTime). + append(", nodeStartTime=").append(nodeStartTime). + append(", threadCnt=").append(threadCnt). + append(", peakThreadCnt=").append(peakThreadCnt). + append(", startedThreadCnt=").append(startedThreadCnt). + append(", daemonThreadCnt=").append(daemonThreadCnt). + append(", fileSysFreeSpace=").append(fileSysFreeSpace). + append(", fileSysTotalSpace=").append(fileSysTotalSpace). + append(", fileSysUsableSpace=").append(fileSysUsableSpace). + append(", lastDataVer=").append(lastDataVer). + append(", sentMsgsCnt=").append(sentMsgsCnt). + append(", sentBytesCnt=").append(sentBytesCnt). + append(", rcvdMsgsCnt=").append(rcvdMsgsCnt). + append(", rcvdBytesCnt=").append(rcvdBytesCnt). + append("]"). + toString(); + } + + /** {@inheritDoc} */ + @Override public void writePortable(PortableWriter writer) throws PortableException { + PortableRawWriter raw = writer.rawWriter(); + + raw.writeLong(lastUpdateTime); + raw.writeInt(maxActiveJobs); + raw.writeInt(curActiveJobs); + raw.writeFloat(avgActiveJobs); + raw.writeInt(maxWaitingJobs); + raw.writeInt(curWaitingJobs); + raw.writeFloat(avgWaitingJobs); + raw.writeInt(maxRejectedJobs); + raw.writeInt(curRejectedJobs); + raw.writeFloat(avgRejectedJobs); + raw.writeInt(maxCancelledJobs); + raw.writeInt(curCancelledJobs); + raw.writeFloat(avgCancelledJobs); + raw.writeInt(totalRejectedJobs); + raw.writeInt(totalCancelledJobs); + raw.writeInt(totalExecutedJobs); + raw.writeLong(maxJobWaitTime); + raw.writeLong(curJobWaitTime); + raw.writeDouble(avgJobWaitTime); + raw.writeLong(maxJobExecTime); + raw.writeLong(curJobExecTime); + raw.writeDouble(avgJobExecTime); + raw.writeInt(totalExecTasks); + raw.writeLong(totalIdleTime); + raw.writeLong(curIdleTime); + raw.writeInt(availProcs); + raw.writeDouble(load); + raw.writeDouble(avgLoad); + raw.writeDouble(gcLoad); + raw.writeLong(heapInit); + raw.writeLong(heapUsed); + raw.writeLong(heapCommitted); + raw.writeLong(heapMax); + raw.writeLong(nonHeapInit); + raw.writeLong(nonHeapUsed); + raw.writeLong(nonHeapCommitted); + raw.writeLong(nonHeapMax); + raw.writeLong(upTime); + raw.writeLong(startTime); + raw.writeLong(nodeStartTime); + raw.writeInt(threadCnt); + raw.writeInt(peakThreadCnt); + raw.writeLong(startedThreadCnt); + raw.writeInt(daemonThreadCnt); + raw.writeLong(fileSysFreeSpace); + raw.writeLong(fileSysTotalSpace); + raw.writeLong(fileSysUsableSpace); + raw.writeLong(lastDataVer); + raw.writeInt(sentMsgsCnt); + raw.writeLong(sentBytesCnt); + raw.writeInt(rcvdMsgsCnt); + raw.writeLong(rcvdBytesCnt); + } + + /** {@inheritDoc} */ + @Override public void readPortable(PortableReader reader) throws PortableException { + PortableRawReader raw = reader.rawReader(); + + lastUpdateTime = raw.readLong(); + maxActiveJobs = raw.readInt(); + curActiveJobs = raw.readInt(); + avgActiveJobs = raw.readFloat(); + maxWaitingJobs = raw.readInt(); + curWaitingJobs = raw.readInt(); + avgWaitingJobs = raw.readFloat(); + maxRejectedJobs = raw.readInt(); + curRejectedJobs = raw.readInt(); + avgRejectedJobs = raw.readFloat(); + maxCancelledJobs = raw.readInt(); + curCancelledJobs = raw.readInt(); + avgCancelledJobs = raw.readFloat(); + totalRejectedJobs = raw.readInt(); + totalCancelledJobs = raw.readInt(); + totalExecutedJobs = raw.readInt(); + maxJobWaitTime = raw.readLong(); + curJobWaitTime = raw.readLong(); + avgJobWaitTime = raw.readDouble(); + maxJobExecTime = raw.readLong(); + curJobExecTime = raw.readLong(); + avgJobExecTime = raw.readDouble(); + totalExecTasks = raw.readInt(); + totalIdleTime = raw.readLong(); + curIdleTime = raw.readLong(); + availProcs = raw.readInt(); + load = raw.readDouble(); + avgLoad = raw.readDouble(); + gcLoad = raw.readDouble(); + heapInit = raw.readLong(); + heapUsed = raw.readLong(); + heapCommitted = raw.readLong(); + heapMax = raw.readLong(); + nonHeapInit = raw.readLong(); + nonHeapUsed = raw.readLong(); + nonHeapCommitted = raw.readLong(); + nonHeapMax = raw.readLong(); + upTime = raw.readLong(); + startTime = raw.readLong(); + nodeStartTime = raw.readLong(); + threadCnt = raw.readInt(); + peakThreadCnt = raw.readInt(); + startedThreadCnt = raw.readLong(); + daemonThreadCnt = raw.readInt(); + fileSysFreeSpace = raw.readLong(); + fileSysTotalSpace = raw.readLong(); + fileSysUsableSpace = raw.readLong(); + lastDataVer = raw.readLong(); + sentMsgsCnt = raw.readInt(); + sentBytesCnt = raw.readLong(); + rcvdMsgsCnt = raw.readInt(); + rcvdBytesCnt = raw.readLong(); + } + + /** {@inheritDoc} */ + @Override public void writeExternal(ObjectOutput out) throws IOException { + out.writeLong(lastUpdateTime); + out.writeInt(maxActiveJobs); + out.writeInt(curActiveJobs); + out.writeFloat(avgActiveJobs); + out.writeInt(maxWaitingJobs); + out.writeInt(curWaitingJobs); + out.writeFloat(avgWaitingJobs); + out.writeInt(maxRejectedJobs); + out.writeInt(curRejectedJobs); + out.writeFloat(avgRejectedJobs); + out.writeInt(maxCancelledJobs); + out.writeInt(curCancelledJobs); + out.writeFloat(avgCancelledJobs); + out.writeInt(totalRejectedJobs); + out.writeInt(totalCancelledJobs); + out.writeInt(totalExecutedJobs); + out.writeLong(maxJobWaitTime); + out.writeLong(curJobWaitTime); + out.writeDouble(avgJobWaitTime); + out.writeLong(maxJobExecTime); + out.writeLong(curJobExecTime); + out.writeDouble(avgJobExecTime); + out.writeInt(totalExecTasks); + out.writeLong(totalIdleTime); + out.writeLong(curIdleTime); + out.writeInt(availProcs); + out.writeDouble(load); + out.writeDouble(avgLoad); + out.writeDouble(gcLoad); + out.writeLong(heapInit); + out.writeLong(heapUsed); + out.writeLong(heapCommitted); + out.writeLong(heapMax); + out.writeLong(nonHeapInit); + out.writeLong(nonHeapUsed); + out.writeLong(nonHeapCommitted); + out.writeLong(nonHeapMax); + out.writeLong(upTime); + out.writeLong(startTime); + out.writeLong(nodeStartTime); + out.writeInt(threadCnt); + out.writeInt(peakThreadCnt); + out.writeLong(startedThreadCnt); + out.writeInt(daemonThreadCnt); + out.writeLong(fileSysFreeSpace); + out.writeLong(fileSysTotalSpace); + out.writeLong(fileSysUsableSpace); + out.writeLong(lastDataVer); + out.writeInt(sentMsgsCnt); + out.writeLong(sentBytesCnt); + out.writeInt(rcvdMsgsCnt); + out.writeLong(rcvdBytesCnt); + } + + /** {@inheritDoc} */ + @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { + lastUpdateTime = in.readLong(); + maxActiveJobs = in.readInt(); + curActiveJobs = in.readInt(); + avgActiveJobs = in.readFloat(); + maxWaitingJobs = in.readInt(); + curWaitingJobs = in.readInt(); + avgWaitingJobs = in.readFloat(); + maxRejectedJobs = in.readInt(); + curRejectedJobs = in.readInt(); + avgRejectedJobs = in.readFloat(); + maxCancelledJobs = in.readInt(); + curCancelledJobs = in.readInt(); + avgCancelledJobs = in.readFloat(); + totalRejectedJobs = in.readInt(); + totalCancelledJobs = in.readInt(); + totalExecutedJobs = in.readInt(); + maxJobWaitTime = in.readLong(); + curJobWaitTime = in.readLong(); + avgJobWaitTime = in.readDouble(); + maxJobExecTime = in.readLong(); + curJobExecTime = in.readLong(); + avgJobExecTime = in.readDouble(); + totalExecTasks = in.readInt(); + totalIdleTime = in.readLong(); + curIdleTime = in.readLong(); + availProcs = in.readInt(); + load = in.readDouble(); + avgLoad = in.readDouble(); + gcLoad = in.readDouble(); + heapInit = in.readLong(); + heapUsed = in.readLong(); + heapCommitted = in.readLong(); + heapMax = in.readLong(); + nonHeapInit = in.readLong(); + nonHeapUsed = in.readLong(); + nonHeapCommitted = in.readLong(); + nonHeapMax = in.readLong(); + upTime = in.readLong(); + startTime = in.readLong(); + nodeStartTime = in.readLong(); + threadCnt = in.readInt(); + peakThreadCnt = in.readInt(); + startedThreadCnt = in.readLong(); + daemonThreadCnt = in.readInt(); + fileSysFreeSpace = in.readLong(); + fileSysTotalSpace = in.readLong(); + fileSysUsableSpace = in.readLong(); + lastDataVer = in.readLong(); + sentMsgsCnt = in.readInt(); + sentBytesCnt = in.readLong(); + rcvdMsgsCnt = in.readInt(); + rcvdBytesCnt = in.readLong(); + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1b0e45a2/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientPingPacket.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientPingPacket.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientPingPacket.java new file mode 100644 index 0000000..fef8a8d --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientPingPacket.java @@ -0,0 +1,37 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal.processors.rest.client.message; + +/** + * Fictive ping packet. + */ +public class GridClientPingPacket extends GridClientAbstractMessage { + /** */ + private static final long serialVersionUID = 0L; + + /** Ping message. */ + public static final GridClientMessage PING_MESSAGE = new GridClientPingPacket(); + + /** Ping packet. */ + public static final byte[] PING_PACKET = new byte[] {(byte)0x90, 0x00, 0x00, 0x00, 0x00}; + + /** {@inheritDoc} */ + @Override public String toString() { + return getClass().getName(); + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1b0e45a2/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientPingPacketWrapper.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientPingPacketWrapper.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientPingPacketWrapper.java new file mode 100644 index 0000000..6fd95b5 --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientPingPacketWrapper.java @@ -0,0 +1,89 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal.processors.rest.client.message; + +import org.apache.ignite.internal.util.direct.*; +import org.apache.ignite.internal.util.typedef.internal.*; + +import java.nio.*; + +/** + * Ping packet wrapper for direct marshalling. + */ +public class GridClientPingPacketWrapper extends GridTcpCommunicationMessageAdapter { + /** */ + private static final long serialVersionUID = -3956036611004055629L; + + /** Ping message size (always zero). */ + private int size; + + /** {@inheritDoc} */ + @Override public boolean writeTo(ByteBuffer buf) { + commState.setBuffer(buf); + + if (!commState.typeWritten) { + if (!commState.putByte(directType())) + return false; + + commState.typeWritten = true; + } + + switch (commState.idx) { + case 0: + if (!commState.putIntClient(size)) + return false; + + commState.idx++; + + } + + return true; + } + + /** {@inheritDoc} */ + @Override public boolean readFrom(ByteBuffer buf) { + throw new UnsupportedOperationException(); + } + + /** {@inheritDoc} */ + @Override public byte directType() { + return GridClientMessageWrapper.REQ_HEADER; + } + + /** {@inheritDoc} */ + @SuppressWarnings({"CloneDoesntCallSuperClone", "CloneCallsConstructors"}) + @Override public GridTcpCommunicationMessageAdapter clone() { + GridClientPingPacketWrapper _clone = new GridClientPingPacketWrapper(); + + clone0(_clone); + + return _clone; + } + + /** {@inheritDoc} */ + @Override protected void clone0(GridTcpCommunicationMessageAdapter _msg) { + GridClientPingPacketWrapper _clone = (GridClientPingPacketWrapper)_msg; + + _clone.size = size; + } + + /** {@inheritDoc} */ + @Override public String toString() { + return S.toString(GridClientPingPacketWrapper.class, this); + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1b0e45a2/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientPortableMetaData.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientPortableMetaData.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientPortableMetaData.java new file mode 100644 index 0000000..6e84b7f --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientPortableMetaData.java @@ -0,0 +1,93 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal.processors.rest.client.message; + +import org.apache.ignite.portables.*; +import org.apache.ignite.internal.util.typedef.internal.*; + +import java.util.*; + +/** + * Portable meta data sent from client. + */ +public class GridClientPortableMetaData implements PortableMarshalAware { + /** */ + private int typeId; + + /** */ + private String typeName; + + /** */ + private Map<String, Integer> fields; + + /** */ + private String affKeyFieldName; + + /** + * @return Type ID. + */ + public int typeId() { + return typeId; + } + + /** + * @return Type name. + */ + public String typeName() { + return typeName; + } + + /** + * @return Fields. + */ + public Map<String, Integer> fields() { + return fields; + } + + /** + * @return Affinity key field name. + */ + public String affinityKeyFieldName() { + return affKeyFieldName; + } + + /** {@inheritDoc} */ + @Override public void writePortable(PortableWriter writer) throws PortableException { + PortableRawWriter raw = writer.rawWriter(); + + raw.writeInt(typeId); + raw.writeString(typeName); + raw.writeString(affKeyFieldName); + raw.writeMap(fields); + } + + /** {@inheritDoc} */ + @Override public void readPortable(PortableReader reader) throws PortableException { + PortableRawReader raw = reader.rawReader(); + + typeId = raw.readInt(); + typeName = raw.readString(); + affKeyFieldName = raw.readString(); + fields = raw.readMap(); + } + + /** {@inheritDoc} */ + @Override public String toString() { + return S.toString(GridClientPortableMetaData.class, this); + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1b0e45a2/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientPutMetaDataRequest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientPutMetaDataRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientPutMetaDataRequest.java new file mode 100644 index 0000000..5bef31b --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientPutMetaDataRequest.java @@ -0,0 +1,64 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal.processors.rest.client.message; + +import org.apache.ignite.portables.*; +import org.apache.ignite.internal.util.typedef.internal.*; + +import java.util.*; + +/** + * Metadata put request. + */ +public class GridClientPutMetaDataRequest extends GridClientAbstractMessage { + /** */ + private static final long serialVersionUID = 0L; + + /** */ + private Collection<GridClientPortableMetaData> meta; + + /** + * @return Type IDs. + */ + public Collection<GridClientPortableMetaData> metaData() { + return meta; + } + + /** {@inheritDoc} */ + @Override public void writePortable(PortableWriter writer) throws PortableException { + super.writePortable(writer); + + PortableRawWriter raw = writer.rawWriter(); + + raw.writeCollection(meta); + } + + /** {@inheritDoc} */ + @Override public void readPortable(PortableReader reader) throws PortableException { + super.readPortable(reader); + + PortableRawReader raw = reader.rawReader(); + + meta = raw.readCollection(); + } + + /** {@inheritDoc} */ + @Override public String toString() { + return S.toString(GridClientPutMetaDataRequest.class, this); + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1b0e45a2/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientResponse.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientResponse.java new file mode 100644 index 0000000..ca97bc3 --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientResponse.java @@ -0,0 +1,145 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal.processors.rest.client.message; + +import org.apache.ignite.portables.*; +import org.apache.ignite.internal.util.typedef.internal.*; + +import java.io.*; + +/** + * Bean representing client operation result. + */ +public class GridClientResponse extends GridClientAbstractMessage { + /** */ + private static final long serialVersionUID = 0L; + + /** Command succeeded. */ + public static final int STATUS_SUCCESS = 0; + + /** Command failed. */ + public static final int STATUS_FAILED = 1; + + /** Authentication failure. */ + public static final int STATUS_AUTH_FAILURE = 2; + + /** Operation security failure. */ + public static final int STATUS_SECURITY_CHECK_FAILED = 3; + + /** Success flag */ + private int successStatus; + + /** Error message, if any. */ + private String errorMsg; + + /** Result object. */ + private Object res; + + /** + * @return {@code True} if this request was successful. + */ + public int successStatus() { + return successStatus; + } + + /** + * @param successStatus Whether request was successful. + */ + public void successStatus(int successStatus) { + this.successStatus = successStatus; + } + + /** + * @return Error message, if any error occurred, or {@code null}. + */ + public String errorMessage() { + return errorMsg; + } + + /** + * @param errorMsg Error message, if any error occurred. + */ + public void errorMessage(String errorMsg) { + this.errorMsg = errorMsg; + } + + /** + * @return Request result. + */ + public Object result() { + return res; + } + + /** + * @param res Request result. + */ + public void result(Object res) { + this.res = res; + } + + /** {@inheritDoc} */ + @Override public void writePortable(PortableWriter writer) throws PortableException { + super.writePortable(writer); + + PortableRawWriter raw = writer.rawWriter(); + + raw.writeInt(successStatus); + raw.writeString(errorMsg); + raw.writeObject(res); + } + + /** {@inheritDoc} */ + @Override public void readPortable(PortableReader reader) throws PortableException { + super.readPortable(reader); + + PortableRawReader raw = reader.rawReader(); + + successStatus = raw.readInt(); + errorMsg = raw.readString(); + res = raw.readObject(); + } + + /** {@inheritDoc} */ + @Override public void writeExternal(ObjectOutput out) throws IOException { + super.writeExternal(out); + + out.writeInt(successStatus); + + U.writeString(out, errorMsg); + + out.writeObject(res); + } + + /** {@inheritDoc} */ + @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { + super.readExternal(in); + + successStatus = in.readInt(); + + errorMsg = U.readString(in); + + res = in.readObject(); + } + + /** {@inheritDoc} */ + @Override public String toString() { + return getClass().getSimpleName() + " [clientId=" + clientId() + ", reqId=" + requestId() + ", " + + "destId=" + destinationId() + ", status=" + successStatus + ", errMsg=" + errorMessage() + + ", result=" + res + "]"; + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1b0e45a2/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientTaskRequest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientTaskRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientTaskRequest.java new file mode 100644 index 0000000..5b833ae --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientTaskRequest.java @@ -0,0 +1,152 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal.processors.rest.client.message; + +import org.apache.ignite.internal.util.portable.*; +import org.apache.ignite.portables.*; +import org.apache.ignite.internal.util.typedef.internal.*; + +import java.io.*; + +/** + * {@code Task} command request. + */ +public class GridClientTaskRequest extends GridClientAbstractMessage { + /** */ + private static final long serialVersionUID = 0L; + + /** Task name. */ + private String taskName; + + /** Task parameter. */ + private Object arg; + + /** Keep portables flag. */ + private boolean keepPortables; + + /** + * @return Task name. + */ + public String taskName() { + return taskName; + } + + /** + * @param taskName Task name. + */ + public void taskName(String taskName) { + this.taskName = taskName; + } + + /** + * @return Arguments. + */ + public Object argument() { + return arg; + } + + /** + * @param arg Arguments. + */ + public void argument(Object arg) { + this.arg = arg; + } + + /** + * @return Keep portables flag. + */ + public boolean keepPortables() { + return keepPortables; + } + + /** + * @param keepPortables Keep portables flag. + */ + public void keepPortables(boolean keepPortables) { + this.keepPortables = keepPortables; + } + + /** {@inheritDoc} */ + @Override public boolean equals(Object o) { + if (this == o) + return true; + + if (o == null || getClass() != o.getClass()) + return false; + + GridClientTaskRequest other = (GridClientTaskRequest)o; + + return (taskName == null ? other.taskName == null : taskName.equals(other.taskName)) && + arg == null ? other.arg == null : arg.equals(other.arg); + } + + /** {@inheritDoc} */ + @Override public int hashCode() { + return (taskName == null ? 0 : taskName.hashCode()) + + 31 * (arg == null ? 0 : arg.hashCode()); + } + + /** {@inheritDoc} */ + @Override public void writePortable(PortableWriter writer) throws PortableException { + super.writePortable(writer); + + PortableRawWriterEx raw = (PortableRawWriterEx)writer.rawWriter(); + + raw.writeString(taskName); + raw.writeBoolean(keepPortables); + + if (keepPortables) + raw.writeObjectDetached(arg); + else + raw.writeObject(arg); + } + + /** {@inheritDoc} */ + @Override public void readPortable(PortableReader reader) throws PortableException { + super.readPortable(reader); + + PortableRawReaderEx raw = (PortableRawReaderEx)reader.rawReader(); + + taskName = raw.readString(); + keepPortables = raw.readBoolean(); + arg = keepPortables ? raw.readObjectDetached() : raw.readObject(); + } + + /** {@inheritDoc} */ + @Override public void writeExternal(ObjectOutput out) throws IOException { + super.writeExternal(out); + + U.writeString(out, taskName); + + out.writeObject(arg); + } + + /** {@inheritDoc} */ + @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { + super.readExternal(in); + + taskName = U.readString(in); + + arg = in.readObject(); + } + + /** {@inheritDoc} */ + @Override public String toString() { + return getClass().getSimpleName() + " [taskName=" + taskName + ", arg=" + arg + "]"; + } +}
