http://git-wip-us.apache.org/repos/asf/ignite/blob/12dfe9e8/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheStoreConfiguration.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheStoreConfiguration.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheStoreConfiguration.java index fd3d980..dc1ba2a 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheStoreConfiguration.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheStoreConfiguration.java @@ -17,14 +17,17 @@ package org.apache.ignite.internal.visor.cache; -import java.io.Serializable; +import java.io.IOException; +import java.io.ObjectInput; +import java.io.ObjectOutput; import org.apache.ignite.cache.store.CacheStore; import org.apache.ignite.cache.store.jdbc.CacheAbstractJdbcStore; import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.internal.IgniteEx; -import org.apache.ignite.internal.LessNamingBean; import org.apache.ignite.internal.processors.cache.IgniteCacheProxy; import org.apache.ignite.internal.util.typedef.internal.S; +import org.apache.ignite.internal.util.typedef.internal.U; +import org.apache.ignite.internal.visor.VisorDataTransferObject; import org.jetbrains.annotations.Nullable; import static org.apache.ignite.internal.visor.util.VisorTaskUtils.compactClass; @@ -32,7 +35,7 @@ import static org.apache.ignite.internal.visor.util.VisorTaskUtils.compactClass; /** * Data transfer object for cache store configuration properties. */ -public class VisorCacheStoreConfiguration implements Serializable, LessNamingBean { +public class VisorCacheStoreConfiguration extends VisorDataTransferObject { /** */ private static final long serialVersionUID = 0L; @@ -70,11 +73,19 @@ public class VisorCacheStoreConfiguration implements Serializable, LessNamingBea private boolean storeKeepBinary; /** + * Default constructor. + */ + public VisorCacheStoreConfiguration() { + // No-op. + } + + /** + * Create data transfer object for cache store configuration properties. + * * @param ignite Ignite instance. * @param ccfg Cache configuration. - * @return Data transfer object for cache store configuration properties. */ - public VisorCacheStoreConfiguration from(IgniteEx ignite, CacheConfiguration ccfg) { + public VisorCacheStoreConfiguration(IgniteEx ignite, CacheConfiguration ccfg) { IgniteCacheProxy<Object, Object> c = ignite.context().cache().jcache(ccfg.getName()); CacheStore cstore = c != null && c.context().started() ? c.context().store().configuredStore() : null; @@ -94,95 +105,123 @@ public class VisorCacheStoreConfiguration implements Serializable, LessNamingBea flushThreadCnt = ccfg.getWriteBehindFlushThreadCount(); storeKeepBinary = ccfg.isStoreKeepBinary(); - - return this; } /** * @return {@code true} if cache has store. */ - public boolean enabled() { + public boolean isEnabled() { return store != null; } /** * @return {@code true} if cache has JDBC store. */ - public boolean jdbcStore() { + public boolean isJdbcStore() { return jdbcStore; } /** * @return Cache store class name. */ - @Nullable public String store() { + @Nullable public String getStore() { return store; } /** * @return Cache store factory class name.. */ - public String storeFactory() { + public String getStoreFactory() { return storeFactory; } /** * @return Whether cache should operate in read-through mode. */ - public boolean readThrough() { + public boolean isReadThrough() { return readThrough; } /** * @return Whether cache should operate in write-through mode. */ - public boolean writeThrough() { + public boolean isWriteThrough() { return writeThrough; } /** * @return Flag indicating whether write-behind behaviour should be used for the cache store. */ - public boolean writeBehindEnabled() { + public boolean isWriteBehindEnabled() { return writeBehindEnabled; } /** * @return Maximum batch size for write-behind cache store operations. */ - public int batchSize() { + public int getBatchSize() { return batchSz; } /** * @return Frequency with which write-behind cache is flushed to the cache store in milliseconds. */ - public long flushFrequency() { + public long getFlushFrequency() { return flushFreq; } /** * @return Maximum object count in write-behind cache. */ - public int flushSize() { + public int getFlushSize() { return flushSz; } /** * @return Number of threads that will perform cache flushing. */ - public int flushThreadCount() { + public int getFlushThreadCount() { return flushThreadCnt; } /** * @return Keep binary in store flag. */ - public boolean storeKeepBinary() { + public boolean isStoreKeepBinary() { return storeKeepBinary; } /** {@inheritDoc} */ + @Override protected void writeExternalData(ObjectOutput out) throws IOException { + out.writeBoolean(jdbcStore); + U.writeString(out, store); + U.writeString(out, storeFactory); + out.writeBoolean(readThrough); + out.writeBoolean(writeThrough); + out.writeBoolean(writeBehindEnabled); + out.writeInt(batchSz); + out.writeLong(flushFreq); + out.writeInt(flushSz); + out.writeInt(flushThreadCnt); + out.writeBoolean(storeKeepBinary); + } + + /** {@inheritDoc} */ + @Override protected void readExternalData(byte protoVer, ObjectInput in) throws IOException, ClassNotFoundException { + jdbcStore = in.readBoolean(); + store = U.readString(in); + storeFactory = U.readString(in); + readThrough = in.readBoolean(); + writeThrough = in.readBoolean(); + writeBehindEnabled = in.readBoolean(); + batchSz = in.readInt(); + flushFreq = in.readLong(); + flushSz = in.readInt(); + flushThreadCnt = in.readInt(); + storeKeepBinary = in.readBoolean(); + } + + /** {@inheritDoc} */ @Override public String toString() { return S.toString(VisorCacheStoreConfiguration.class, this); }
http://git-wip-us.apache.org/repos/asf/ignite/blob/12dfe9e8/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheTypeFieldMetadata.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheTypeFieldMetadata.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheTypeFieldMetadata.java deleted file mode 100644 index c9bf960..0000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheTypeFieldMetadata.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * 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.visor.cache; - -import java.io.Serializable; -import org.apache.ignite.cache.store.jdbc.JdbcTypeField; -import org.apache.ignite.internal.LessNamingBean; - -/** - * Data transfer object for {@link JdbcTypeField}. - */ -public class VisorCacheTypeFieldMetadata implements Serializable, LessNamingBean { - /** */ - private static final long serialVersionUID = 0L; - - /** Column name in database. */ - private String dbName; - - /** Column JDBC type in database. */ - private int dbType; - - /** Field name in java object. */ - private String javaName; - - /** Corresponding java type. */ - private String javaType; - - /** - * Empty constructor. - */ - public VisorCacheTypeFieldMetadata() { - // No-op. - } - - /** - * Full constructor. - * - * @param dbName Column name in database. - * @param dbType Column JDBC type in database. - * @param javaName Field name in java object. - * @param javaType Corresponding java type. - */ - public VisorCacheTypeFieldMetadata(String dbName, int dbType, String javaName, String javaType) { - this.dbName = dbName; - this.dbType = dbType; - this.javaName = javaName; - this.javaType = javaType; - } - - /** - * @return Column name in database. - */ - public String dbName() { - return dbName; - } - - /** - * @return Column JDBC type in database. - */ - public int dbType() { - return dbType; - } - - /** - * @return Field name in java object. - */ - public String javaName() { - return javaName; - } - - /** - * @return Corresponding java type. - */ - public String javaType() { - return javaType; - } -} http://git-wip-us.apache.org/repos/asf/ignite/blob/12dfe9e8/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheTypeMetadata.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheTypeMetadata.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheTypeMetadata.java deleted file mode 100644 index 7463887..0000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheTypeMetadata.java +++ /dev/null @@ -1,294 +0,0 @@ -/* - * 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.visor.cache; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.LinkedHashMap; -import java.util.Map; -import org.apache.ignite.cache.QueryEntity; -import org.apache.ignite.cache.QueryIndex; -import org.apache.ignite.cache.store.jdbc.CacheJdbcPojoStoreFactory; -import org.apache.ignite.cache.store.jdbc.JdbcType; -import org.apache.ignite.cache.store.jdbc.JdbcTypeField; -import org.apache.ignite.internal.LessNamingBean; -import org.apache.ignite.internal.util.tostring.GridToStringInclude; -import org.apache.ignite.internal.util.typedef.internal.S; -import org.apache.ignite.internal.util.typedef.internal.U; -import org.apache.ignite.lang.IgniteBiTuple; - -import javax.cache.configuration.Factory; - -/** - * Data transfer object for {@link JdbcType}. - */ -public class VisorCacheTypeMetadata implements Serializable, LessNamingBean { - /** */ - private static final long serialVersionUID = 0L; - - /** Schema name in database. */ - private String dbSchema; - - /** Table name in database. */ - private String dbTbl; - - /** Key class used to store key in cache. */ - private String keyType; - - /** Value class used to store value in cache. */ - private String valType; - - /** Key fields. */ - @GridToStringInclude - private Collection<VisorCacheTypeFieldMetadata> keyFields; - - /** Value fields. */ - @GridToStringInclude - private Collection<VisorCacheTypeFieldMetadata> valFields; - - /** Fields to be queried, in addition to indexed fields. */ - @GridToStringInclude - private Map<String, String> qryFlds; - - /** Fields to index in ascending order. */ - @GridToStringInclude - private Map<String, String> ascFlds; - - /** Fields to index in descending order. */ - @GridToStringInclude - private Map<String, String> descFlds; - - /** Fields to index as text. */ - @GridToStringInclude - private Collection<String> txtFlds; - - /** Fields to create group indexes for. */ - @GridToStringInclude - private Map<String, LinkedHashMap<String, IgniteBiTuple<String, Boolean>>> grps; - - /** - * @param qryEntities Collection of query entities. - * @param factory Store factory to extract JDBC types info. - * @return Data transfer object for cache type metadata configurations. - */ - public static Collection<VisorCacheTypeMetadata> list(Collection<QueryEntity> qryEntities, Factory factory) { - final Collection<VisorCacheTypeMetadata> metas = new ArrayList<>(); - - Map<String, VisorCacheTypeMetadata> metaMap = - U.newHashMap(qryEntities != null ? qryEntities.size() : 0); - - // Add query entries. - if (qryEntities != null) - for (QueryEntity qryEntity : qryEntities) { - VisorCacheTypeMetadata meta = from(qryEntity); - - metas.add(meta); - - metaMap.put(meta.keyType, meta); - } - - // Add JDBC types. - if (factory != null && factory instanceof CacheJdbcPojoStoreFactory) { - CacheJdbcPojoStoreFactory jdbcFactory = (CacheJdbcPojoStoreFactory) factory; - - JdbcType[] jdbcTypes = jdbcFactory.getTypes(); - - if (jdbcTypes != null && jdbcTypes.length > 0) { - for (JdbcType jdbcType : jdbcTypes) { - VisorCacheTypeMetadata meta = metaMap.get(jdbcType.getKeyType()); - - boolean notFound = meta == null; - - if (notFound) { - meta = new VisorCacheTypeMetadata(); - - meta.keyType = jdbcType.getKeyType(); - meta.valType = jdbcType.getValueType(); - - meta.qryFlds = Collections.emptyMap(); - meta.ascFlds = Collections.emptyMap(); - meta.descFlds = Collections.emptyMap(); - meta.txtFlds = Collections.emptyList(); - meta.grps = Collections.emptyMap(); - } - - meta.dbSchema = jdbcType.getDatabaseSchema(); - meta.dbTbl = jdbcType.getDatabaseTable(); - - JdbcTypeField[] keyFields = jdbcType.getKeyFields(); - - if (keyFields != null) { - meta.keyFields = new ArrayList<>(keyFields.length); - - for (JdbcTypeField fld : keyFields) - meta.keyFields.add(new VisorCacheTypeFieldMetadata( - fld.getDatabaseFieldName(), fld.getDatabaseFieldType(), - fld.getDatabaseFieldName(), U.compact(fld.getJavaFieldType().getName()))); - } - - JdbcTypeField[] valFields = jdbcType.getValueFields(); - - if (valFields != null) { - meta.valFields = new ArrayList<>(valFields.length); - - for (JdbcTypeField fld : valFields) - meta.valFields.add(new VisorCacheTypeFieldMetadata( - fld.getDatabaseFieldName(), fld.getDatabaseFieldType(), - fld.getDatabaseFieldName(), U.compact(fld.getJavaFieldType().getName()))); - } - - if (notFound) - metas.add(meta); - } - } - } - - return metas; - } - - /** - * @param q Actual cache query entities. - * @return Data transfer object for given cache type metadata. - */ - public static VisorCacheTypeMetadata from(QueryEntity q) { - assert q != null; - - VisorCacheTypeMetadata metadata = new VisorCacheTypeMetadata(); - - metadata.keyType = q.getKeyType(); - metadata.valType = q.getValueType(); - - metadata.dbSchema = ""; - metadata.dbTbl = ""; - - metadata.keyFields = Collections.emptyList(); - metadata.valFields = Collections.emptyList(); - - LinkedHashMap<String, String> qryFields = q.getFields(); - - metadata.qryFlds = new LinkedHashMap<>(qryFields); - - metadata.ascFlds = Collections.emptyMap(); - metadata.descFlds = Collections.emptyMap(); - metadata.txtFlds = Collections.emptyList(); - - Collection<QueryIndex> qryIdxs = q.getIndexes(); - - metadata.grps = new LinkedHashMap<>(qryIdxs.size()); - - for (QueryIndex qryIdx : qryIdxs) { - LinkedHashMap<String, Boolean> qryIdxFlds = qryIdx.getFields(); - - LinkedHashMap<String, IgniteBiTuple<String, Boolean>> grpFlds = new LinkedHashMap<>(); - - for (Map.Entry<String, Boolean> qryIdxFld : qryIdxFlds.entrySet()) { - String fldName = qryIdxFld.getKey(); - - grpFlds.put(fldName, new IgniteBiTuple<>(qryFields.get(fldName), !qryIdxFld.getValue())); - } - - metadata.grps.put(qryIdx.getName(), grpFlds); - } - - return metadata; - } - - /** - * @return Schema name in database. - */ - public String dbSchema() { - return dbSchema; - } - - /** - * @return Table name in database. - */ - public String dbTbl() { - return dbTbl; - } - - /** - * @return Key class used to store key in cache. - */ - public String keyType() { - return keyType; - } - - /** - * @return Value class used to store value in cache. - */ - public String valType() { - return valType; - } - - /** - * @return Key fields. - */ - public Collection<VisorCacheTypeFieldMetadata> keyFields() { - return keyFields; - } - - /** - * @return Value fields. - */ - public Collection<VisorCacheTypeFieldMetadata> valFields() { - return valFields; - } - - /** - * @return Fields to be queried, in addition to indexed fields. - */ - public Map<String, String> qryFlds() { - return qryFlds; - } - - /** - * @return Fields to index in ascending order. - */ - public Map<String, String> ascFlds() { - return ascFlds; - } - - /** - * @return Fields to index in descending order. - */ - public Map<String, String> descFlds() { - return descFlds; - } - - /** - * @return Fields to index as text. - */ - public Collection<String> txtFlds() { - return txtFlds; - } - - /** - * @return Fields to create group indexes for. - */ - public Map<String, LinkedHashMap<String, IgniteBiTuple<String, Boolean>>> grps() { - return grps; - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorCacheTypeMetadata.class, this); - } -} http://git-wip-us.apache.org/repos/asf/ignite/blob/12dfe9e8/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorPartitionMap.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorPartitionMap.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorPartitionMap.java new file mode 100644 index 0000000..f263db5 --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorPartitionMap.java @@ -0,0 +1,90 @@ +/* + * 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.visor.cache; + +import java.io.IOException; +import java.io.ObjectInput; +import java.io.ObjectOutput; +import java.util.Map; +import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtPartitionState; +import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionMap; +import org.apache.ignite.internal.util.typedef.internal.S; +import org.apache.ignite.internal.util.typedef.internal.U; +import org.apache.ignite.internal.visor.VisorDataTransferObject; + +/** + * Data transfer object for partitions map. + */ +public class VisorPartitionMap extends VisorDataTransferObject { + /** */ + private static final long serialVersionUID = 0L; + + /** Map of partition states. */ + private Map<Integer, GridDhtPartitionState> parts; + + /** + * Default constructor. + */ + public VisorPartitionMap() { + // No-op. + } + + /** + * @param map Partitions map. + */ + public VisorPartitionMap(GridDhtPartitionMap map) { + parts = map.map(); + } + + /** + * @return Partitions map. + */ + public Map<Integer, GridDhtPartitionState> getPartitions() { + return parts; + } + + /** + * @return Partitions map size. + */ + public int size() { + return parts.size(); + } + + /** + * @param part Partition. + * @return Partition state. + */ + public GridDhtPartitionState get(Integer part) { + return parts.get(part); + } + + /** {@inheritDoc} */ + @Override protected void writeExternalData(ObjectOutput out) throws IOException { + U.writeIntKeyMap(out, parts); + } + + /** {@inheritDoc} */ + @Override protected void readExternalData(byte protoVer, ObjectInput in) throws IOException, ClassNotFoundException { + parts = U.readIntKeyMap(in); + } + + /** {@inheritDoc} */ + @Override public String toString() { + return S.toString(VisorPartitionMap.class, this); + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/12dfe9e8/modules/core/src/main/java/org/apache/ignite/internal/visor/compute/VisorComputeMonitoringHolder.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/compute/VisorComputeMonitoringHolder.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/compute/VisorComputeMonitoringHolder.java index 01d6f4f..42eb4f5 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/compute/VisorComputeMonitoringHolder.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/compute/VisorComputeMonitoringHolder.java @@ -55,7 +55,7 @@ public class VisorComputeMonitoringHolder { cleanupStopped = false; } - listenVisor.put(visorKey, true); + listenVisor.put(visorKey, Boolean.TRUE); ignite.events().enableLocal(VISOR_TASK_EVTS); } @@ -68,7 +68,7 @@ public class VisorComputeMonitoringHolder { * @return {@code true} if task events should remain enabled. */ private boolean tryDisableEvents(IgniteEx ignite) { - if (!listenVisor.values().contains(true)) { + if (!listenVisor.values().contains(Boolean.TRUE)) { listenVisor.clear(); ignite.events().disableLocal(VISOR_TASK_EVTS); @@ -103,7 +103,7 @@ public class VisorComputeMonitoringHolder { synchronized (listenVisor) { if (tryDisableEvents(ignite)) { for (String visorKey : listenVisor.keySet()) - listenVisor.put(visorKey, false); + listenVisor.put(visorKey, Boolean.FALSE); scheduleCleanupJob(ignite); } @@ -118,4 +118,4 @@ public class VisorComputeMonitoringHolder { @Override public String toString() { return S.toString(VisorComputeMonitoringHolder.class, this); } -} \ No newline at end of file +} http://git-wip-us.apache.org/repos/asf/ignite/blob/12dfe9e8/modules/core/src/main/java/org/apache/ignite/internal/visor/compute/VisorComputeToggleMonitoringTask.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/compute/VisorComputeToggleMonitoringTask.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/compute/VisorComputeToggleMonitoringTask.java index ae66d4b..e9bd940 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/compute/VisorComputeToggleMonitoringTask.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/compute/VisorComputeToggleMonitoringTask.java @@ -26,7 +26,6 @@ import org.apache.ignite.internal.processors.task.GridInternal; import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.internal.visor.VisorJob; import org.apache.ignite.internal.visor.VisorMultiNodeTask; -import org.apache.ignite.lang.IgniteBiTuple; import org.jetbrains.annotations.Nullable; import static org.apache.ignite.internal.visor.compute.VisorComputeMonitoringHolder.COMPUTE_MONITORING_HOLDER_KEY; @@ -38,7 +37,7 @@ import static org.apache.ignite.internal.visor.util.VisorTaskUtils.checkExplicit */ @GridInternal public class VisorComputeToggleMonitoringTask extends - VisorMultiNodeTask<IgniteBiTuple<String, Boolean>, Boolean, Boolean> { + VisorMultiNodeTask<VisorComputeToggleMonitoringTaskArg, Boolean, Boolean> { /** */ private static final long serialVersionUID = 0L; @@ -54,14 +53,14 @@ public class VisorComputeToggleMonitoringTask extends } /** {@inheritDoc} */ - @Override protected VisorComputeToggleMonitoringJob job(IgniteBiTuple<String, Boolean> arg) { + @Override protected VisorComputeToggleMonitoringJob job(VisorComputeToggleMonitoringTaskArg arg) { return new VisorComputeToggleMonitoringJob(arg, debug); } /** * Job to toggle task monitoring on node. */ - private static class VisorComputeToggleMonitoringJob extends VisorJob<IgniteBiTuple<String, Boolean>, Boolean> { + private static class VisorComputeToggleMonitoringJob extends VisorJob<VisorComputeToggleMonitoringTaskArg, Boolean> { /** */ private static final long serialVersionUID = 0L; @@ -69,41 +68,40 @@ public class VisorComputeToggleMonitoringTask extends * @param arg Visor ID key and monitoring state flag. * @param debug Debug flag. */ - private VisorComputeToggleMonitoringJob(IgniteBiTuple<String, Boolean> arg, boolean debug) { + private VisorComputeToggleMonitoringJob(VisorComputeToggleMonitoringTaskArg arg, boolean debug) { super(arg, debug); } /** {@inheritDoc} */ - @Override protected Boolean run(IgniteBiTuple<String, Boolean> arg) { + @Override protected Boolean run(VisorComputeToggleMonitoringTaskArg arg) { if (checkExplicitTaskMonitoring(ignite)) - return true; - else { - ConcurrentMap<String, VisorComputeMonitoringHolder> storage = ignite.cluster().nodeLocalMap(); + return Boolean.TRUE; - VisorComputeMonitoringHolder holder = storage.get(COMPUTE_MONITORING_HOLDER_KEY); + ConcurrentMap<String, VisorComputeMonitoringHolder> storage = ignite.cluster().nodeLocalMap(); - if (holder == null) { - VisorComputeMonitoringHolder holderNew = new VisorComputeMonitoringHolder(); + VisorComputeMonitoringHolder holder = storage.get(COMPUTE_MONITORING_HOLDER_KEY); - VisorComputeMonitoringHolder holderOld = - storage.putIfAbsent(COMPUTE_MONITORING_HOLDER_KEY, holderNew); + if (holder == null) { + VisorComputeMonitoringHolder holderNew = new VisorComputeMonitoringHolder(); - holder = holderOld == null ? holderNew : holderOld; - } + VisorComputeMonitoringHolder holderOld = + storage.putIfAbsent(COMPUTE_MONITORING_HOLDER_KEY, holderNew); - String visorKey = arg.get1(); + holder = holderOld == null ? holderNew : holderOld; + } - boolean state = arg.get2(); + String visorKey = arg.getVisorKey(); - // Set task monitoring state. - if (state) - holder.startCollect(ignite, visorKey); - else - holder.stopCollect(ignite, visorKey); + boolean state = arg.isEnabled(); - // Return actual state. It could stay the same if events explicitly enabled in configuration. - return ignite.allEventsUserRecordable(VISOR_TASK_EVTS); - } + // Set task monitoring state. + if (state) + holder.startCollect(ignite, visorKey); + else + holder.stopCollect(ignite, visorKey); + + // Return actual state. It could stay the same if events explicitly enabled in configuration. + return ignite.allEventsUserRecordable(VISOR_TASK_EVTS); } /** {@inheritDoc} */ @@ -111,4 +109,4 @@ public class VisorComputeToggleMonitoringTask extends return S.toString(VisorComputeToggleMonitoringJob.class, this); } } -} \ No newline at end of file +} http://git-wip-us.apache.org/repos/asf/ignite/blob/12dfe9e8/modules/core/src/main/java/org/apache/ignite/internal/visor/compute/VisorComputeToggleMonitoringTaskArg.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/compute/VisorComputeToggleMonitoringTaskArg.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/compute/VisorComputeToggleMonitoringTaskArg.java new file mode 100644 index 0000000..e17379a --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/compute/VisorComputeToggleMonitoringTaskArg.java @@ -0,0 +1,86 @@ +/* + * 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.visor.compute; + +import java.io.IOException; +import java.io.ObjectInput; +import java.io.ObjectOutput; +import org.apache.ignite.internal.util.typedef.internal.S; +import org.apache.ignite.internal.util.typedef.internal.U; +import org.apache.ignite.internal.visor.VisorDataTransferObject; + +/** + * Toggle compute monitoring arguments. + */ +public class VisorComputeToggleMonitoringTaskArg extends VisorDataTransferObject { + /** */ + private static final long serialVersionUID = 0L; + + /** Visor monitoring id */ + private String visorKey; + + /** Enable state of compute monitoring */ + private boolean enabled; + + /** + * Default constructor. + */ + public VisorComputeToggleMonitoringTaskArg() { + // No-op. + } + + /** + * @param visorKey Visor monitoring id. + * @param enabled Enable state of compute monitoring. + */ + public VisorComputeToggleMonitoringTaskArg(String visorKey, boolean enabled) { + this.visorKey = visorKey; + this.enabled = enabled; + } + + /** + * @return Visor monitoring id. + */ + public String getVisorKey() { + return visorKey; + } + + /** + * @return Enable state of compute monitoring. + */ + public boolean isEnabled() { + return enabled; + } + + /** {@inheritDoc} */ + @Override protected void writeExternalData(ObjectOutput out) throws IOException { + U.writeString(out, visorKey); + out.writeBoolean(enabled); + } + + /** {@inheritDoc} */ + @Override protected void readExternalData(byte protoVer, ObjectInput in) throws IOException, ClassNotFoundException { + visorKey = U.readString(in); + enabled = in.readBoolean(); + } + + /** {@inheritDoc} */ + @Override public String toString() { + return S.toString(VisorComputeToggleMonitoringTaskArg.class, this); + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/12dfe9e8/modules/core/src/main/java/org/apache/ignite/internal/visor/compute/VisorGatewayTask.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/compute/VisorGatewayTask.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/compute/VisorGatewayTask.java index 1113ca1..22cd460 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/compute/VisorGatewayTask.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/compute/VisorGatewayTask.java @@ -277,7 +277,7 @@ public class VisorGatewayTask implements ComputeTask<Object[], Object> { byte[] res = new byte[els.length]; for (int i = 0; i < els.length; i ++) - res[i] = Byte.valueOf(els[i]); + res[i] = Byte.valueOf(els[i]); return res; } @@ -348,7 +348,7 @@ public class VisorGatewayTask implements ComputeTask<Object[], Object> { } } - final Collection<UUID> nids; + final List<UUID> nids; if (nidsArg == null || "null".equals(nidsArg) || nidsArg.isEmpty()) { Collection<ClusterNode> nodes = ignite.cluster().nodes(); http://git-wip-us.apache.org/repos/asf/ignite/blob/12dfe9e8/modules/core/src/main/java/org/apache/ignite/internal/visor/debug/VisorThreadDumpTask.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/debug/VisorThreadDumpTask.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/debug/VisorThreadDumpTask.java index 68cfdb3..9c6aa60 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/debug/VisorThreadDumpTask.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/debug/VisorThreadDumpTask.java @@ -24,13 +24,12 @@ import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.internal.visor.VisorJob; import org.apache.ignite.internal.visor.VisorOneNodeTask; -import org.apache.ignite.lang.IgniteBiTuple; /** * Creates thread dump. */ @GridInternal -public class VisorThreadDumpTask extends VisorOneNodeTask<Void, IgniteBiTuple<VisorThreadInfo[], long[]>> { +public class VisorThreadDumpTask extends VisorOneNodeTask<Void, VisorThreadDumpTaskResult> { /** */ private static final long serialVersionUID = 0L; @@ -42,7 +41,7 @@ public class VisorThreadDumpTask extends VisorOneNodeTask<Void, IgniteBiTuple<Vi /** * Job that take thread dump on node. */ - private static class VisorDumpThreadJob extends VisorJob<Void, IgniteBiTuple<VisorThreadInfo[], long[]>> { + private static class VisorDumpThreadJob extends VisorJob<Void, VisorThreadDumpTaskResult> { /** */ private static final long serialVersionUID = 0L; @@ -55,7 +54,7 @@ public class VisorThreadDumpTask extends VisorOneNodeTask<Void, IgniteBiTuple<Vi } /** {@inheritDoc} */ - @Override protected IgniteBiTuple<VisorThreadInfo[], long[]> run(Void arg) { + @Override protected VisorThreadDumpTaskResult run(Void arg) { ThreadMXBean mx = U.getThreadMx(); ThreadInfo[] info = mx.dumpAllThreads(true, true); @@ -63,9 +62,9 @@ public class VisorThreadDumpTask extends VisorOneNodeTask<Void, IgniteBiTuple<Vi VisorThreadInfo[] visorInfo = new VisorThreadInfo[info.length]; for (int i = 0; i < info.length; i++) - visorInfo[i] = VisorThreadInfo.from(info[i]); + visorInfo[i] = new VisorThreadInfo(info[i]); - return new IgniteBiTuple<>(visorInfo, mx.findDeadlockedThreads()); + return new VisorThreadDumpTaskResult(visorInfo, mx.findDeadlockedThreads()); } /** {@inheritDoc} */ @@ -73,4 +72,4 @@ public class VisorThreadDumpTask extends VisorOneNodeTask<Void, IgniteBiTuple<Vi return S.toString(VisorDumpThreadJob.class, this); } } -} \ No newline at end of file +} http://git-wip-us.apache.org/repos/asf/ignite/blob/12dfe9e8/modules/core/src/main/java/org/apache/ignite/internal/visor/debug/VisorThreadDumpTaskResult.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/debug/VisorThreadDumpTaskResult.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/debug/VisorThreadDumpTaskResult.java new file mode 100644 index 0000000..f6e0161 --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/debug/VisorThreadDumpTaskResult.java @@ -0,0 +1,88 @@ +/* + * 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.visor.debug; + +import java.io.IOException; +import java.io.ObjectInput; +import java.io.ObjectOutput; +import java.lang.management.ThreadInfo; +import org.apache.ignite.internal.util.typedef.internal.S; +import org.apache.ignite.internal.visor.VisorDataTransferObject; + +/** + * Data transfer object for Visor {@link ThreadInfo}. + */ +public class VisorThreadDumpTaskResult extends VisorDataTransferObject { + /** */ + private static final long serialVersionUID = 0L; + + /** List of information about threads. */ + private VisorThreadInfo[] threadInfo; + + /** List of deadlocked thread ids. */ + private long[] deadlockedThreads; + + /** + * Default constructor. + */ + public VisorThreadDumpTaskResult() { + // No-op. + } + + /** + * Create data transfer object for given thread info. + * + * @param threadInfo Thread info. + * @param deadlockedThreads Thread info. + */ + public VisorThreadDumpTaskResult(VisorThreadInfo[] threadInfo, long[] deadlockedThreads) { + this.threadInfo = threadInfo; + this.deadlockedThreads = deadlockedThreads; + } + + /** + * @return List of information about threads. + */ + public VisorThreadInfo[] getThreadInfo() { + return threadInfo; + } + + /** + * @return List of deadlocked thread ids. + */ + public long[] getDeadlockedThreads() { + return deadlockedThreads; + } + + /** {@inheritDoc} */ + @Override protected void writeExternalData(ObjectOutput out) throws IOException { + out.writeObject(threadInfo); + out.writeObject(deadlockedThreads); + } + + /** {@inheritDoc} */ + @Override protected void readExternalData(byte protoVer, ObjectInput in) throws IOException, ClassNotFoundException { + threadInfo = (VisorThreadInfo[])in.readObject(); + deadlockedThreads = (long[])in.readObject(); + } + + /** {@inheritDoc} */ + @Override public String toString() { + return S.toString(VisorThreadDumpTaskResult.class, this); + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/12dfe9e8/modules/core/src/main/java/org/apache/ignite/internal/visor/debug/VisorThreadInfo.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/debug/VisorThreadInfo.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/debug/VisorThreadInfo.java index d656ad1..3db4074 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/debug/VisorThreadInfo.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/debug/VisorThreadInfo.java @@ -17,14 +17,21 @@ package org.apache.ignite.internal.visor.debug; -import java.io.Serializable; +import java.io.IOException; +import java.io.ObjectInput; +import java.io.ObjectOutput; import java.lang.management.ThreadInfo; -import org.apache.ignite.internal.LessNamingBean; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import org.apache.ignite.internal.util.typedef.F; +import org.apache.ignite.internal.util.typedef.internal.U; +import org.apache.ignite.internal.visor.VisorDataTransferObject; /** * Data transfer object for Visor {@link ThreadInfo}. */ -public class VisorThreadInfo implements Serializable, LessNamingBean { +public class VisorThreadInfo extends VisorDataTransferObject { /** */ private static final long serialVersionUID = 0L; @@ -32,241 +39,260 @@ public class VisorThreadInfo implements Serializable, LessNamingBean { private static final int MAX_FRAMES = 8; /** Thread name. */ - private final String name; + private String name; /** Thread ID. */ - private final Long id; + private Long id; /** Thread state. */ - private final Thread.State state; + private Thread.State state; /** Lock information. */ - private final VisorThreadLockInfo lock; + private VisorThreadLockInfo lock; /** Lock name. */ - private final String lockName; + private String lockName; /** Lock owner thread ID. */ - private final Long lockOwnerId; + private Long lockOwnerId; /** Lock owner name. */ - private final String lockOwnerName; + private String lockOwnerName; /** Thread executing native code. */ - private final Boolean inNative; + private Boolean inNative; /** Thread is suspended. */ - private final Boolean suspended; + private Boolean suspended; /** Waited count. */ - private final Long waitedCnt; + private Long waitedCnt; /** Waited time. */ - private final Long waitedTime; + private Long waitedTime; /** Blocked count. */ - private final Long blockedCnt; + private Long blockedCnt; /** Blocked time. */ - private final Long blockedTime; + private Long blockedTime; /** Stack trace. */ - private final StackTraceElement[] stackTrace; + private List<StackTraceElement> stackTrace; /** Locks info. */ - private final VisorThreadLockInfo[] locks; + private List<VisorThreadLockInfo> locks; /** Locked monitors. */ - private final VisorThreadMonitorInfo[] lockedMonitors; - - /** Create thread info with given parameters. */ - public VisorThreadInfo(String name, - Long id, - Thread.State state, - VisorThreadLockInfo lock, - String lockName, - Long lockOwnerId, - String lockOwnerName, - Boolean inNative, - Boolean suspended, - Long waitedCnt, - Long waitedTime, - Long blockedCnt, - Long blockedTime, - StackTraceElement[] stackTrace, - VisorThreadLockInfo[] locks, - VisorThreadMonitorInfo[] lockedMonitors - ) { - this.name = name; - this.id = id; - this.state = state; - this.lock = lock; - this.lockName = lockName; - this.lockOwnerId = lockOwnerId; - this.lockOwnerName = lockOwnerName; - this.inNative = inNative; - this.suspended = suspended; - this.waitedCnt = waitedCnt; - this.waitedTime = waitedTime; - this.blockedCnt = blockedCnt; - this.blockedTime = blockedTime; - this.stackTrace = stackTrace; - this.locks = locks; - this.lockedMonitors = lockedMonitors; + private List<VisorThreadMonitorInfo> lockedMonitors; + + /** + * Default constructor. + */ + public VisorThreadInfo() { + // No-op. } - /** Create data transfer object for given thread info. */ - public static VisorThreadInfo from(ThreadInfo ti) { + /** + * Create data transfer object for given thread info. + * + * @param ti Thread info. + */ + public VisorThreadInfo(ThreadInfo ti) { assert ti != null; - VisorThreadLockInfo[] linfos = ti.getLockedSynchronizers() != null ? - new VisorThreadLockInfo[ti.getLockedSynchronizers().length] : null; + name = ti.getThreadName(); + id = ti.getThreadId(); + state = ti.getThreadState(); + lock = ti.getLockInfo() != null ? new VisorThreadLockInfo(ti.getLockInfo()) : null; + lockName =ti.getLockName(); + lockOwnerId = ti.getLockOwnerId(); + lockOwnerName = ti.getLockOwnerName(); + inNative = ti.isInNative(); + suspended = ti.isSuspended(); + waitedCnt = ti.getWaitedCount(); + waitedTime = ti.getWaitedTime(); + blockedCnt = ti.getBlockedCount(); + blockedTime = ti.getBlockedTime(); + stackTrace = Arrays.asList(ti.getStackTrace()); + + locks = ti.getLockedSynchronizers() != null ? + new ArrayList<VisorThreadLockInfo>(ti.getLockedSynchronizers().length) : null; if (ti.getLockedSynchronizers() != null) for (int i = 0; i < ti.getLockedSynchronizers().length; i++) - linfos[i] = VisorThreadLockInfo.from(ti.getLockedSynchronizers()[i]); + locks.add(new VisorThreadLockInfo(ti.getLockedSynchronizers()[i])); - VisorThreadMonitorInfo[] minfos = ti.getLockedMonitors() != null ? - new VisorThreadMonitorInfo[ti.getLockedMonitors().length] : null; + lockedMonitors = ti.getLockedMonitors() != null ? + new ArrayList<VisorThreadMonitorInfo>(ti.getLockedMonitors().length) : null; if (ti.getLockedMonitors() != null) for (int i = 0; i < ti.getLockedMonitors().length; i++) - minfos[i] = VisorThreadMonitorInfo.from(ti.getLockedMonitors()[i]); - - return new VisorThreadInfo(ti.getThreadName(), - ti.getThreadId(), - ti.getThreadState(), - ti.getLockInfo() != null ? VisorThreadLockInfo.from(ti.getLockInfo()) : null, - ti.getLockName(), - ti.getLockOwnerId(), - ti.getLockOwnerName(), - ti.isInNative(), - ti.isSuspended(), - ti.getWaitedCount(), - ti.getWaitedTime(), - ti.getBlockedCount(), - ti.getBlockedTime(), - ti.getStackTrace(), - linfos, - minfos - ); + lockedMonitors.add(new VisorThreadMonitorInfo(ti.getLockedMonitors()[i])); } /** * @return Thread name. */ - public String name() { + public String getName() { return name; } /** * @return Thread ID. */ - public Long id() { + public Long getId() { return id; } /** * @return Thread state. */ - public Thread.State state() { + public Thread.State getState() { return state; } /** * @return Lock information. */ - public VisorThreadLockInfo lock() { + public VisorThreadLockInfo getLock() { return lock; } /** * @return Lock name. */ - public String lockName() { + public String getLockName() { return lockName; } /** * @return Lock owner thread ID. */ - public Long lockOwnerId() { + public Long getLockOwnerId() { return lockOwnerId; } /** * @return Lock owner name. */ - public String lockOwnerName() { + public String getLockOwnerName() { return lockOwnerName; } /** * @return Thread executing native code. */ - public Boolean inNative() { + public Boolean isInNative() { return inNative; } /** * @return Thread is suspended. */ - public Boolean suspended() { + public Boolean isSuspended() { return suspended; } /** * @return Waited count. */ - public Long waitedCount() { + public Long getWaitedCount() { return waitedCnt; } /** * @return Waited time. */ - public Long waitedTime() { + public Long getWaitedTime() { return waitedTime; } /** * @return Blocked count. */ - public Long blockedCount() { + public Long getBlockedCount() { return blockedCnt; } /** * @return Blocked time. */ - public Long blockedTime() { + public Long getBlockedTime() { return blockedTime; } /** * @return Stack trace. */ - public StackTraceElement[] stackTrace() { + public List<StackTraceElement> getStackTrace() { return stackTrace; } /** * @return Locks info. */ - public VisorThreadLockInfo[] locks() { + public List<VisorThreadLockInfo> getLocks() { return locks; } /** * @return Locked monitors. */ - public VisorThreadMonitorInfo[] lockedMonitors() { + public List<VisorThreadMonitorInfo> getLockedMonitors() { return lockedMonitors; } /** {@inheritDoc} */ + @Override protected void writeExternalData(ObjectOutput out) throws IOException { + U.writeString(out, name); + out.writeObject(id); + U.writeString(out, state.toString()); + out.writeObject(lock); + U.writeString(out, lockName); + out.writeObject(lockOwnerId); + U.writeString(out, lockOwnerName); + out.writeObject(inNative); + out.writeObject(suspended); + out.writeObject(waitedCnt); + out.writeObject(waitedTime); + out.writeObject(blockedCnt); + out.writeObject(blockedTime); + U.writeCollection(out, stackTrace); + U.writeCollection(out, locks); + U.writeCollection(out, lockedMonitors); + } + + /** {@inheritDoc} */ + @Override protected void readExternalData(byte protoVer, ObjectInput in) throws IOException, ClassNotFoundException { + name = U.readString(in); + id = (Long)in.readObject(); + + String statePresentation = U.readString(in); + + if (statePresentation != null) + state = Enum.valueOf(Thread.State.class, statePresentation); + + lock = (VisorThreadLockInfo)in.readObject(); + lockName = U.readString(in); + lockOwnerId = (Long)in.readObject(); + lockOwnerName = U.readString(in); + inNative = (Boolean)in.readObject(); + suspended = (Boolean)in.readObject(); + waitedCnt = (Long)in.readObject(); + waitedTime = (Long)in.readObject(); + blockedCnt = (Long)in.readObject(); + blockedTime = (Long)in.readObject(); + stackTrace = U.readList(in); + locks = U.readList(in); + lockedMonitors = U.readList(in); + } + + /** {@inheritDoc} */ @Override public String toString() { - StringBuilder sb = new StringBuilder("\"" + name + "\"" + " Id=" + id + " " + state); + StringBuilder sb = new StringBuilder(512); + + sb.append('"').append(name).append('"').append(" Id=").append(id).append(' ').append(state); if (lockName != null) sb.append(" on ").append(lockName); @@ -282,12 +308,12 @@ public class VisorThreadInfo implements Serializable, LessNamingBean { sb.append('\n'); - int maxFrames = Math.min(stackTrace.length, MAX_FRAMES); + int maxFrames = Math.min(stackTrace.size(), MAX_FRAMES); for (int i = 0; i < maxFrames; i++) { - StackTraceElement ste = stackTrace[i]; + StackTraceElement ste = stackTrace.get(i); - sb.append("\tat ").append(ste.toString()).append('\n'); + sb.append("\tat ").append(ste).append('\n'); if (i == 0 && lock != null) { switch (state) { @@ -308,16 +334,16 @@ public class VisorThreadInfo implements Serializable, LessNamingBean { } for (VisorThreadMonitorInfo mi : lockedMonitors) { - if (mi.stackDepth() == i) + if (mi.getStackDepth() == i) sb.append("\t- locked ").append(mi).append('\n'); } } - if (maxFrames < stackTrace.length) + if (maxFrames < stackTrace.size()) sb.append("\t...").append('\n'); - if (locks.length > 0) { - sb.append("\n\tNumber of locked synchronizers = ").append(locks.length).append('\n'); + if (!F.isEmpty(locks)) { + sb.append("\n\tNumber of locked synchronizers = ").append(locks.size()).append('\n'); for (VisorThreadLockInfo li : locks) sb.append("\t- ").append(li).append('\n'); http://git-wip-us.apache.org/repos/asf/ignite/blob/12dfe9e8/modules/core/src/main/java/org/apache/ignite/internal/visor/debug/VisorThreadLockInfo.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/debug/VisorThreadLockInfo.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/debug/VisorThreadLockInfo.java index 0fdd95f..4aab0e0 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/debug/VisorThreadLockInfo.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/debug/VisorThreadLockInfo.java @@ -17,57 +17,76 @@ package org.apache.ignite.internal.visor.debug; -import java.io.Serializable; +import java.io.IOException; +import java.io.ObjectInput; +import java.io.ObjectOutput; import java.lang.management.LockInfo; -import org.apache.ignite.internal.LessNamingBean; +import org.apache.ignite.internal.util.typedef.internal.U; +import org.apache.ignite.internal.visor.VisorDataTransferObject; /** * Data transfer object for {@link LockInfo}. */ -public class VisorThreadLockInfo implements Serializable, LessNamingBean { +public class VisorThreadLockInfo extends VisorDataTransferObject { /** */ private static final long serialVersionUID = 0L; /** * Fully qualified name of the class of the lock object. */ - protected final String clsName; + protected String clsName; /** * Identity hash code of the lock object. */ - protected final Integer identityHashCode; + protected Integer identityHashCode; - /** Create thread lock info with given parameters. */ - public VisorThreadLockInfo(String clsName, Integer identityHashCode) { - assert clsName != null; - - this.clsName = clsName; - this.identityHashCode = identityHashCode; + /** + * Default constructor. + */ + public VisorThreadLockInfo() { + // No-op. } - /** Create data transfer object for given lock info. */ - public static VisorThreadLockInfo from(LockInfo li) { + /** + * Create data transfer object for given lock info. + * + * @param li Lock info. + */ + public VisorThreadLockInfo(LockInfo li) { assert li != null; - return new VisorThreadLockInfo(li.getClassName(), li.getIdentityHashCode()); + clsName = li.getClassName(); + identityHashCode = li.getIdentityHashCode(); } /** * @return Fully qualified name of the class of the lock object. */ - public String className() { + public String getClassName() { return clsName; } /** * @return Identity hash code of the lock object. */ - public Integer identityHashCode() { + public Integer getIdentityHashCode() { return identityHashCode; } /** {@inheritDoc} */ + @Override protected void writeExternalData(ObjectOutput out) throws IOException { + U.writeString(out, clsName); + out.writeObject(identityHashCode); + } + + /** {@inheritDoc} */ + @Override protected void readExternalData(byte protoVer, ObjectInput in) throws IOException, ClassNotFoundException { + clsName = U.readString(in); + identityHashCode = (Integer)in.readObject(); + } + + /** {@inheritDoc} */ @Override public String toString() { return clsName + '@' + Integer.toHexString(identityHashCode); } http://git-wip-us.apache.org/repos/asf/ignite/blob/12dfe9e8/modules/core/src/main/java/org/apache/ignite/internal/visor/debug/VisorThreadMonitorInfo.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/debug/VisorThreadMonitorInfo.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/debug/VisorThreadMonitorInfo.java index cc68665..11e1141 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/debug/VisorThreadMonitorInfo.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/debug/VisorThreadMonitorInfo.java @@ -17,7 +17,13 @@ package org.apache.ignite.internal.visor.debug; +import java.io.IOException; +import java.io.ObjectInput; +import java.io.ObjectOutput; import java.lang.management.MonitorInfo; +import org.apache.ignite.internal.util.typedef.internal.S; +import org.apache.ignite.internal.visor.VisorDataTransferObjectInput; +import org.apache.ignite.internal.visor.VisorDataTransferObjectOutput; /** * Data transfer object for {@link MonitorInfo}. @@ -27,46 +33,72 @@ public class VisorThreadMonitorInfo extends VisorThreadLockInfo { private static final long serialVersionUID = 0L; /** Stack depth. */ - private final Integer stackDepth; + private Integer stackDepth; /** Stack frame. */ - private final StackTraceElement stackFrame; + private StackTraceElement stackFrame; /** - * Create thread monitor info with given parameters. - * - * @param clsName Fully qualified name of the class of the lock object. - * @param identityHashCode Identity hash code of the lock object. - * @param stackDepth Depth in the stack trace where the object monitor was locked. - * @param stackFrame Stack frame that locked the object monitor. + * Default constructor. */ - public VisorThreadMonitorInfo(String clsName, Integer identityHashCode, Integer stackDepth, - StackTraceElement stackFrame) { - super(clsName, identityHashCode); - - this.stackDepth = stackDepth; - this.stackFrame = stackFrame; + public VisorThreadMonitorInfo() { + // No-op. } - /** Create data transfer object for given monitor info. */ - public static VisorThreadMonitorInfo from(MonitorInfo mi) { - assert mi != null; + /** + * Create data transfer object for given monitor info. + * + * @param mi Monitoring info. + */ + public VisorThreadMonitorInfo(MonitorInfo mi) { + super(mi); - return new VisorThreadMonitorInfo(mi.getClassName(), mi.getIdentityHashCode(), mi.getLockedStackDepth(), - mi.getLockedStackFrame()); + stackDepth = mi.getLockedStackDepth(); + stackFrame = mi.getLockedStackFrame(); } /** * @return Stack depth. */ - public Integer stackDepth() { + public Integer getStackDepth() { return stackDepth; } /** * @return Stack frame. */ - public StackTraceElement stackFrame() { + public StackTraceElement getStackFrame() { return stackFrame; } -} \ No newline at end of file + + /** {@inheritDoc} */ + @Override public byte getProtocolVersion() { + return 1; + } + + /** {@inheritDoc} */ + @Override protected void writeExternalData(ObjectOutput out) throws IOException { + try (VisorDataTransferObjectOutput dtout = new VisorDataTransferObjectOutput(out)) { + dtout.writeByte(super.getProtocolVersion()); + super.writeExternalData(dtout); + } + + out.writeObject(stackDepth); + out.writeObject(stackFrame); + } + + /** {@inheritDoc} */ + @Override protected void readExternalData(byte protoVer, ObjectInput in) throws IOException, ClassNotFoundException { + try (VisorDataTransferObjectInput dtin = new VisorDataTransferObjectInput(in)) { + super.readExternalData(dtin.readByte(), dtin); + } + + stackDepth = (Integer)in.readObject(); + stackFrame = (StackTraceElement)in.readObject(); + } + + /** {@inheritDoc} */ + @Override public String toString() { + return S.toString(VisorThreadMonitorInfo.class, this); + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/12dfe9e8/modules/core/src/main/java/org/apache/ignite/internal/visor/event/VisorGridDeploymentEvent.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/event/VisorGridDeploymentEvent.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/event/VisorGridDeploymentEvent.java index 0eefa6b..1d41e19 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/event/VisorGridDeploymentEvent.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/event/VisorGridDeploymentEvent.java @@ -17,8 +17,14 @@ package org.apache.ignite.internal.visor.event; +import java.io.IOException; +import java.io.ObjectInput; +import java.io.ObjectOutput; import java.util.UUID; import org.apache.ignite.internal.util.typedef.internal.S; +import org.apache.ignite.internal.util.typedef.internal.U; +import org.apache.ignite.internal.visor.VisorDataTransferObjectInput; +import org.apache.ignite.internal.visor.VisorDataTransferObjectOutput; import org.apache.ignite.lang.IgniteUuid; import org.jetbrains.annotations.Nullable; @@ -30,7 +36,14 @@ public class VisorGridDeploymentEvent extends VisorGridEvent { private static final long serialVersionUID = 0L; /** Deployment alias. */ - private final String alias; + private String alias; + + /** + * Default constructor. + */ + public VisorGridDeploymentEvent() { + // No-op. + } /** * Create event with given parameters. @@ -62,12 +75,36 @@ public class VisorGridDeploymentEvent extends VisorGridEvent { /** * @return Deployment alias. */ - public String alias() { + public String getAlias() { return alias; } /** {@inheritDoc} */ + @Override public byte getProtocolVersion() { + return 1; + } + + /** {@inheritDoc} */ + @Override protected void writeExternalData(ObjectOutput out) throws IOException { + try (VisorDataTransferObjectOutput dtout = new VisorDataTransferObjectOutput(out)) { + dtout.writeByte(super.getProtocolVersion()); + super.writeExternalData(dtout); + } + + U.writeString(out, alias); + } + + /** {@inheritDoc} */ + @Override protected void readExternalData(byte protoVer, ObjectInput in) throws IOException, ClassNotFoundException { + try (VisorDataTransferObjectInput dtin = new VisorDataTransferObjectInput(in)) { + super.readExternalData(dtin.readByte(), dtin); + } + + alias = U.readString(in); + } + + /** {@inheritDoc} */ @Override public String toString() { return S.toString(VisorGridDeploymentEvent.class, this); } -} \ No newline at end of file +} http://git-wip-us.apache.org/repos/asf/ignite/blob/12dfe9e8/modules/core/src/main/java/org/apache/ignite/internal/visor/event/VisorGridDiscoveryEvent.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/event/VisorGridDiscoveryEvent.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/event/VisorGridDiscoveryEvent.java index bad6966..b4afed9 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/event/VisorGridDiscoveryEvent.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/event/VisorGridDiscoveryEvent.java @@ -17,8 +17,14 @@ package org.apache.ignite.internal.visor.event; +import java.io.IOException; +import java.io.ObjectInput; +import java.io.ObjectOutput; import java.util.UUID; import org.apache.ignite.internal.util.typedef.internal.S; +import org.apache.ignite.internal.util.typedef.internal.U; +import org.apache.ignite.internal.visor.VisorDataTransferObjectInput; +import org.apache.ignite.internal.visor.VisorDataTransferObjectOutput; import org.apache.ignite.lang.IgniteUuid; import org.jetbrains.annotations.Nullable; @@ -30,16 +36,23 @@ public class VisorGridDiscoveryEvent extends VisorGridEvent { private static final long serialVersionUID = 0L; /** Node that caused this event to be generated. */ - private final UUID evtNodeId; + private UUID evtNodeId; /** Node address that caused this event to be generated. */ - private final String addr; + private String addr; /** If node that caused this event is daemon. */ - private final boolean isDaemon; + private boolean isDaemon; /** Topology version. */ - private final long topVer; + private long topVer; + + /** + * Default constructor. + */ + public VisorGridDiscoveryEvent() { + // No-op. + } /** * Create event with given parameters. @@ -78,16 +91,16 @@ public class VisorGridDiscoveryEvent extends VisorGridEvent { } /** - * @return Deployment alias. + * @return Event node ID. */ - public UUID evtNodeId() { + public UUID getEventNodeId() { return evtNodeId; } /** * @return Node address that caused this event to be generated. */ - public String address() { + public String getAddress() { return addr; } @@ -102,11 +115,41 @@ public class VisorGridDiscoveryEvent extends VisorGridEvent { * @return Topology version or {@code 0} if configured discovery SPI implementation * does not support versioning. **/ - public long topologyVersion() { + public long getTopologyVersion() { return topVer; } /** {@inheritDoc} */ + @Override public byte getProtocolVersion() { + return 1; + } + + /** {@inheritDoc} */ + @Override protected void writeExternalData(ObjectOutput out) throws IOException { + try (VisorDataTransferObjectOutput dtout = new VisorDataTransferObjectOutput(out)) { + dtout.writeByte(super.getProtocolVersion()); + super.writeExternalData(dtout); + } + + U.writeUuid(out, evtNodeId); + U.writeString(out, addr); + out.writeBoolean(isDaemon); + out.writeLong(topVer); + } + + /** {@inheritDoc} */ + @Override protected void readExternalData(byte protoVer, ObjectInput in) throws IOException, ClassNotFoundException { + try (VisorDataTransferObjectInput dtin = new VisorDataTransferObjectInput(in)) { + super.readExternalData(dtin.readByte(), dtin); + } + + evtNodeId = U.readUuid(in); + addr = U.readString(in); + isDaemon = in.readBoolean(); + topVer = in.readLong(); + } + + /** {@inheritDoc} */ @Override public String toString() { return S.toString(VisorGridDiscoveryEvent.class, this); } http://git-wip-us.apache.org/repos/asf/ignite/blob/12dfe9e8/modules/core/src/main/java/org/apache/ignite/internal/visor/event/VisorGridEvent.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/event/VisorGridEvent.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/event/VisorGridEvent.java index b24e860..4814aba 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/event/VisorGridEvent.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/event/VisorGridEvent.java @@ -17,40 +17,50 @@ package org.apache.ignite.internal.visor.event; -import java.io.Serializable; +import java.io.IOException; +import java.io.ObjectInput; +import java.io.ObjectOutput; import java.util.UUID; -import org.apache.ignite.internal.LessNamingBean; import org.apache.ignite.internal.util.typedef.internal.S; +import org.apache.ignite.internal.util.typedef.internal.U; +import org.apache.ignite.internal.visor.VisorDataTransferObject; import org.apache.ignite.lang.IgniteUuid; import org.jetbrains.annotations.Nullable; /** * Base class for lightweight counterpart for various {@link org.apache.ignite.events.Event}. */ -public class VisorGridEvent implements Serializable, LessNamingBean { +public class VisorGridEvent extends VisorDataTransferObject { /** */ private static final long serialVersionUID = 0L; /** Event type. */ - private final int typeId; + private int typeId; /** Globally unique ID of this event. */ - private final IgniteUuid id; + private IgniteUuid id; /** Name of this event. */ - private final String name; + private String name; /** Node Id where event occurred and was recorded. */ - private final UUID nid; + private UUID nid; /** Event timestamp. */ - private final long ts; + private long ts; /** Event message. */ - private final String msg; + private String msg; /** Shortened version of {@code toString()} result. Suitable for humans to read. */ - private final String shortDisplay; + private String shortDisplay; + + /** + * Default constructor. + */ + public VisorGridEvent() { + // No-op. + } /** * Create event with given parameters. @@ -77,53 +87,75 @@ public class VisorGridEvent implements Serializable, LessNamingBean { /** * @return Event type. */ - public int typeId() { + public int getTypeId() { return typeId; } /** * @return Globally unique ID of this event. */ - public IgniteUuid id() { + public IgniteUuid getId() { return id; } /** * @return Name of this event. */ - public String name() { + public String getName() { return name; } /** * @return Node Id where event occurred and was recorded. */ - public UUID nid() { + public UUID getNid() { return nid; } /** * @return Event timestamp. */ - public long timestamp() { + public long getTimestamp() { return ts; } /** * @return Event message. */ - @Nullable public String message() { + @Nullable public String getMessage() { return msg; } /** * @return Shortened version of result. Suitable for humans to read. */ - public String shortDisplay() { + public String getShortDisplay() { return shortDisplay; } /** {@inheritDoc} */ + @Override protected void writeExternalData(ObjectOutput out) throws IOException { + out.writeInt(typeId); + U.writeGridUuid(out, id); + U.writeString(out, name); + U.writeUuid(out, nid); + out.writeLong(ts); + U.writeString(out, msg); + U.writeString(out, shortDisplay); + } + + /** {@inheritDoc} */ + @Override protected void readExternalData(byte protoVer, ObjectInput in) throws IOException, ClassNotFoundException { + typeId = in.readInt(); + id = U.readGridUuid(in); + name = U.readString(in); + nid = U.readUuid(in); + ts = in.readLong(); + msg = U.readString(in); + shortDisplay = U.readString(in); + } + + /** {@inheritDoc} */ @Override public String toString() { return S.toString(VisorGridEvent.class, this); } http://git-wip-us.apache.org/repos/asf/ignite/blob/12dfe9e8/modules/core/src/main/java/org/apache/ignite/internal/visor/event/VisorGridEventsLost.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/event/VisorGridEventsLost.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/event/VisorGridEventsLost.java index 92f149a..e07a3a1 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/event/VisorGridEventsLost.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/event/VisorGridEventsLost.java @@ -18,6 +18,7 @@ package org.apache.ignite.internal.visor.event; import java.util.UUID; +import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.lang.IgniteUuid; @@ -29,6 +30,13 @@ public class VisorGridEventsLost extends VisorGridEvent { private static final long serialVersionUID = 0L; /** + * Default constructor. + */ + public VisorGridEventsLost() { + // No-op. + } + + /** * Create event with given parameters. * * @param nid Node where events were lost. @@ -38,4 +46,9 @@ public class VisorGridEventsLost extends VisorGridEvent { "Some Visor events were lost and Visor may show inconsistent results. " + "Configure your grid to disable not important events.", ""); } -} \ No newline at end of file + + /** {@inheritDoc} */ + @Override public String toString() { + return S.toString(VisorGridEventsLost.class, this); + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/12dfe9e8/modules/core/src/main/java/org/apache/ignite/internal/visor/event/VisorGridJobEvent.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/event/VisorGridJobEvent.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/event/VisorGridJobEvent.java index a1a0c04..2e4c627 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/event/VisorGridJobEvent.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/event/VisorGridJobEvent.java @@ -17,8 +17,14 @@ package org.apache.ignite.internal.visor.event; +import java.io.IOException; +import java.io.ObjectInput; +import java.io.ObjectOutput; import java.util.UUID; import org.apache.ignite.internal.util.typedef.internal.S; +import org.apache.ignite.internal.util.typedef.internal.U; +import org.apache.ignite.internal.visor.VisorDataTransferObjectInput; +import org.apache.ignite.internal.visor.VisorDataTransferObjectOutput; import org.apache.ignite.lang.IgniteUuid; import org.jetbrains.annotations.Nullable; @@ -30,16 +36,23 @@ public class VisorGridJobEvent extends VisorGridEvent { private static final long serialVersionUID = 0L; /** Name of the task that triggered the event. */ - private final String taskName; + private String taskName; /** Name of task class that triggered the event. */ - private final String taskClsName; + private String taskClsName; /** Task session ID of the task that triggered the event. */ - private final IgniteUuid taskSesId; + private IgniteUuid taskSesId; /** Job ID. */ - private final IgniteUuid jobId; + private IgniteUuid jobId; + + /** + * Default constructor. + */ + public VisorGridJobEvent() { + // No-op. + } /** * Create event with given parameters. @@ -80,33 +93,63 @@ public class VisorGridJobEvent extends VisorGridEvent { /** * @return Name of the task that triggered the event. */ - public String taskName() { + public String getTaskName() { return taskName; } /** * @return Name of task class that triggered the event. */ - public String taskClassName() { + public String getTaskClassName() { return taskClsName; } /** * @return Task session ID of the task that triggered the event. */ - public IgniteUuid taskSessionId() { + public IgniteUuid getTaskSessionId() { return taskSesId; } /** * @return Job ID. */ - public IgniteUuid jobId() { + public IgniteUuid getJobId() { return jobId; } /** {@inheritDoc} */ + @Override public byte getProtocolVersion() { + return 1; + } + + /** {@inheritDoc} */ + @Override protected void writeExternalData(ObjectOutput out) throws IOException { + try (VisorDataTransferObjectOutput dtout = new VisorDataTransferObjectOutput(out)) { + dtout.writeByte(super.getProtocolVersion()); + super.writeExternalData(dtout); + } + + U.writeString(out, taskName); + U.writeString(out, taskClsName); + U.writeGridUuid(out, taskSesId); + U.writeGridUuid(out, jobId); + } + + /** {@inheritDoc} */ + @Override protected void readExternalData(byte protoVer, ObjectInput in) throws IOException, ClassNotFoundException { + try (VisorDataTransferObjectInput dtin = new VisorDataTransferObjectInput(in)) { + super.readExternalData(dtin.readByte(), dtin); + } + + taskName = U.readString(in); + taskClsName = U.readString(in); + taskSesId = U.readGridUuid(in); + jobId = U.readGridUuid(in); + } + + /** {@inheritDoc} */ @Override public String toString() { return S.toString(VisorGridJobEvent.class, this); } -} \ No newline at end of file +} http://git-wip-us.apache.org/repos/asf/ignite/blob/12dfe9e8/modules/core/src/main/java/org/apache/ignite/internal/visor/event/VisorGridTaskEvent.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/event/VisorGridTaskEvent.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/event/VisorGridTaskEvent.java index 255d559..0f3eee4 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/event/VisorGridTaskEvent.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/event/VisorGridTaskEvent.java @@ -17,8 +17,14 @@ package org.apache.ignite.internal.visor.event; +import java.io.IOException; +import java.io.ObjectInput; +import java.io.ObjectOutput; import java.util.UUID; import org.apache.ignite.internal.util.typedef.internal.S; +import org.apache.ignite.internal.util.typedef.internal.U; +import org.apache.ignite.internal.visor.VisorDataTransferObjectInput; +import org.apache.ignite.internal.visor.VisorDataTransferObjectOutput; import org.apache.ignite.lang.IgniteUuid; import org.jetbrains.annotations.Nullable; @@ -30,16 +36,23 @@ public class VisorGridTaskEvent extends VisorGridEvent { private static final long serialVersionUID = 0L; /** Name of the task that triggered the event. */ - private final String taskName; + private String taskName; /** Name of task class that triggered the event. */ - private final String taskClsName; + private String taskClsName; /** Task session ID. */ - private final IgniteUuid taskSesId; + private IgniteUuid taskSesId; /** Whether task was created for system needs. */ - private final boolean internal; + private boolean internal; + + /** + * Default constructor. + */ + public VisorGridTaskEvent() { + // No-op. + } /** * Create event with given parameters. @@ -80,33 +93,63 @@ public class VisorGridTaskEvent extends VisorGridEvent { /** * @return Name of the task that triggered the event. */ - public String taskName() { + public String getTaskName() { return taskName; } /** * @return Name of task class that triggered the event. */ - public String taskClassName() { + public String getTaskClassName() { return taskClsName; } /** * @return Task session ID. */ - public IgniteUuid taskSessionId() { + public IgniteUuid getTaskSessionId() { return taskSesId; } /** * @return Whether task was created for system needs. */ - public boolean internal() { + public boolean isInternal() { return internal; } /** {@inheritDoc} */ + @Override public byte getProtocolVersion() { + return 1; + } + + /** {@inheritDoc} */ + @Override protected void writeExternalData(ObjectOutput out) throws IOException { + try (VisorDataTransferObjectOutput dtout = new VisorDataTransferObjectOutput(out)) { + dtout.writeByte(super.getProtocolVersion()); + super.writeExternalData(dtout); + } + + U.writeString(out, taskName); + U.writeString(out, taskClsName); + U.writeGridUuid(out, taskSesId); + out.writeBoolean(internal); + } + + /** {@inheritDoc} */ + @Override protected void readExternalData(byte protoVer, ObjectInput in) throws IOException, ClassNotFoundException { + try (VisorDataTransferObjectInput dtin = new VisorDataTransferObjectInput(in)) { + super.readExternalData(dtin.readByte(), dtin); + } + + taskName = U.readString(in); + taskClsName = U.readString(in); + taskSesId = U.readGridUuid(in); + internal = in.readBoolean(); + } + + /** {@inheritDoc} */ @Override public String toString() { return S.toString(VisorGridTaskEvent.class, this); } -} \ No newline at end of file +} http://git-wip-us.apache.org/repos/asf/ignite/blob/12dfe9e8/modules/core/src/main/java/org/apache/ignite/internal/visor/file/VisorFileBlock.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/file/VisorFileBlock.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/file/VisorFileBlock.java index dba7037..23540b5 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/file/VisorFileBlock.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/file/VisorFileBlock.java @@ -17,34 +17,44 @@ package org.apache.ignite.internal.visor.file; -import java.io.Serializable; -import org.apache.ignite.internal.LessNamingBean; +import java.io.IOException; +import java.io.ObjectInput; +import java.io.ObjectOutput; import org.apache.ignite.internal.util.typedef.internal.S; +import org.apache.ignite.internal.util.typedef.internal.U; +import org.apache.ignite.internal.visor.VisorDataTransferObject; /** * Represents block of bytes from a file, could be optionally zipped. */ -public class VisorFileBlock implements Serializable, LessNamingBean { +public class VisorFileBlock extends VisorDataTransferObject { /** */ private static final long serialVersionUID = 0L; /** File path. */ - private final String path; + private String path; /** Marker position. */ - private final long off; + private long off; /** File size. */ - private final long size; + private long size; /** Timestamp of last modification of the file. */ - private final long lastModified; + private long lastModified; /** Whether data was zipped. */ - private final boolean zipped; + private boolean zipped; /** Data bytes. */ - private final byte[] data; + private byte[] data; + + /** + * Default constructor. + */ + public VisorFileBlock() { + + } /** * Create file block with given parameters. @@ -68,46 +78,66 @@ public class VisorFileBlock implements Serializable, LessNamingBean { /** * @return File path. */ - public String path() { + public String getPath() { return path; } /** * @return Marker position. */ - public long offset() { + public long getOffset() { return off; } /** * @return File size. */ - public long size() { + public long getSize() { return size; } /** * @return Timestamp of last modification of the file. */ - public long lastModified() { + public long getLastModified() { return lastModified; } /** * @return Whether data was zipped. */ - public boolean zipped() { + public boolean isZipped() { return zipped; } /** * @return Data bytes. */ - public byte[] data() { + public byte[] getData() { return data; } /** {@inheritDoc} */ + @Override protected void writeExternalData(ObjectOutput out) throws IOException { + U.writeString(out, path); + out.writeLong(off); + out.writeLong(size); + out.writeLong(lastModified); + out.writeBoolean(zipped); + U.writeByteArray(out, data); + } + + /** {@inheritDoc} */ + @Override protected void readExternalData(byte protoVer, ObjectInput in) throws IOException, ClassNotFoundException { + path = U.readString(in); + off = in.readLong(); + size = in.readLong(); + lastModified = in.readLong(); + zipped = in.readBoolean(); + data = U.readByteArray(in); + } + + /** {@inheritDoc} */ @Override public String toString() { return S.toString(VisorFileBlock.class, this); }
