diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/GridRestProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/GridRestProcessor.java index cf6e4c2c164dd..aaaa527c0eac6 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/GridRestProcessor.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/GridRestProcessor.java @@ -81,7 +81,6 @@ import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.internal.util.worker.GridWorker; import org.apache.ignite.internal.util.worker.GridWorkerFuture; -import org.apache.ignite.internal.visor.compute.VisorGatewayTask; import org.apache.ignite.internal.visor.util.VisorClusterGroupEmptyException; import org.apache.ignite.lang.IgniteBiTuple; import org.apache.ignite.lang.IgniteInClosure; @@ -896,10 +895,6 @@ private void authorize(GridRestRequest req) throws SecurityException { GridRestTaskRequest taskReq = (GridRestTaskRequest)req; name = taskReq.taskName(); - // We should extract task name wrapped by VisorGatewayTask. - if (VisorGatewayTask.class.getName().equals(name)) - name = (String)taskReq.params().get(WRAPPED_TASK_IDX); - break; case GET_OR_CREATE_CACHE: diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/VisorCoordinatorNodeTask.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/VisorCoordinatorNodeTask.java deleted file mode 100644 index f744e9ead376d..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/VisorCoordinatorNodeTask.java +++ /dev/null @@ -1,39 +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; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.UUID; -import org.apache.ignite.cluster.ClusterNode; - -/** - * Base class for Visor tasks intended to execute job on coordinator node. - */ -public abstract class VisorCoordinatorNodeTask extends VisorOneNodeTask { - /** {@inheritDoc} */ - @Override protected Collection jobNodes(VisorTaskArgument arg) { - ClusterNode crd = ignite.context().discovery().discoCache().oldestAliveServerNode(); - - Collection nids = new ArrayList<>(1); - - nids.add(crd == null ? ignite.localNode().id() : crd.id()); - - return nids; - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/VisorEither.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/VisorEither.java deleted file mode 100644 index f426e8aaea105..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/VisorEither.java +++ /dev/null @@ -1,103 +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; - -import java.io.Externalizable; -import java.io.IOException; -import java.io.ObjectInput; -import java.io.ObjectOutput; -import org.apache.ignite.internal.util.typedef.internal.S; - -/** - * Base class for Visor result with error. - * - * @param Result type. - */ -public class VisorEither implements Externalizable { - /** */ - private static final long serialVersionUID = 0L; - - /** Exception on execution. */ - private Throwable error; - - /** Result. */ - private T res; - - /** - * Default constructor. - */ - public VisorEither() { - // No-op. - } - - /** - * @param error Exception on execution. - */ - public VisorEither(Throwable error) { - this.error = error; - } - - /** - * @param res Result. - */ - public VisorEither(T res) { - this.res = res; - } - - /** - * @return {@code true} If failed on execution. - */ - public boolean failed() { - return error != null; - } - - /** - * @return Exception on execution. - */ - public Throwable getError() { - return error; - } - - /** - * @return Result. - */ - public T getResult() { - return res; - } - - /** {@inheritDoc} */ - @Override public void writeExternal(ObjectOutput out) throws IOException { - boolean failed = failed(); - - out.writeBoolean(failed); - out.writeObject(failed ? error : res); - } - - /** {@inheritDoc} */ - @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { - if (in.readBoolean()) - error = (Throwable)in.readObject(); - else - res = (T)in.readObject(); - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorEither.class, this); - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/binary/VisorBinaryMetadata.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/binary/VisorBinaryMetadata.java deleted file mode 100644 index 6f7e625574546..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/binary/VisorBinaryMetadata.java +++ /dev/null @@ -1,138 +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.binary; - -import java.io.IOException; -import java.io.ObjectInput; -import java.io.ObjectOutput; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import org.apache.ignite.IgniteBinary; -import org.apache.ignite.binary.BinaryType; -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; - -/** - * Binary object metadata to show in Visor. - */ -public class VisorBinaryMetadata extends VisorDataTransferObject { - /** */ - private static final long serialVersionUID = 0L; - - /** Type name */ - private String typeName; - - /** Type Id */ - private int typeId; - - /** Affinity key field name. */ - private String affinityKeyFieldName; - - /** Filed list */ - private List fields; - - /** - * @param binary Binary objects. - * @return List of data transfer objects for binary objects metadata. - */ - public static List list(IgniteBinary binary) { - List res = new ArrayList<>(); - - if (binary != null) { - for (BinaryType binaryType : binary.types()) - res.add(new VisorBinaryMetadata(binary, binaryType)); - } - - return res; - } - - /** - * Default constructor. - */ - public VisorBinaryMetadata() { - // No-op. - } - - /** - * Default constructor. - */ - public VisorBinaryMetadata(IgniteBinary binary, BinaryType binaryType) { - typeName = binaryType.typeName(); - typeId = binary.typeId(typeName); - affinityKeyFieldName = binaryType.affinityKeyFieldName(); - - Collection binaryTypeFields = binaryType.fieldNames(); - - fields = new ArrayList<>(binaryTypeFields.size()); - - for (String metaField : binaryTypeFields) - fields.add(new VisorBinaryMetadataField(metaField, binaryType.fieldTypeName(metaField), null)); - } - - /** - * @return Type name. - */ - public String getTypeName() { - return typeName; - } - - /** - * @return Type Id. - */ - public int getTypeId() { - return typeId; - } - - /** - * @return Fields list. - */ - public Collection getFields() { - return fields; - } - - /** - * @return Affinity key field name. - */ - @Nullable public String getAffinityKeyFieldName() { - return affinityKeyFieldName; - } - - /** {@inheritDoc} */ - @Override protected void writeExternalData(ObjectOutput out) throws IOException { - U.writeString(out, typeName); - out.writeInt(typeId); - U.writeString(out, affinityKeyFieldName); - U.writeCollection(out, fields); - } - - /** {@inheritDoc} */ - @Override protected void readExternalData(byte protoVer, ObjectInput in) throws IOException, ClassNotFoundException { - typeName = U.readString(in); - typeId = in.readInt(); - affinityKeyFieldName = U.readString(in); - fields = U.readList(in); - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorBinaryMetadata.class, this); - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/binary/VisorBinaryMetadataCollectorTask.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/binary/VisorBinaryMetadataCollectorTask.java deleted file mode 100644 index f210f0db0a016..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/binary/VisorBinaryMetadataCollectorTask.java +++ /dev/null @@ -1,74 +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.binary; - -import org.apache.ignite.IgniteBinary; -import org.apache.ignite.internal.binary.BinaryMarshaller; -import org.apache.ignite.internal.processors.task.GridInternal; -import org.apache.ignite.internal.processors.task.GridVisorManagementTask; -import org.apache.ignite.internal.util.typedef.internal.S; -import org.apache.ignite.internal.visor.VisorJob; -import org.apache.ignite.internal.visor.VisorOneNodeTask; -import org.apache.ignite.marshaller.Marshaller; - -/** - * Task that collects binary metadata. - */ -@GridInternal -@GridVisorManagementTask -public class VisorBinaryMetadataCollectorTask - extends VisorOneNodeTask { - /** */ - private static final long serialVersionUID = 0L; - - /** {@inheritDoc} */ - @Override protected VisorBinaryCollectMetadataJob job(VisorBinaryMetadataCollectorTaskArg lastUpdate) { - return new VisorBinaryCollectMetadataJob(lastUpdate, debug); - } - - /** Job that collect portables metadata on node. */ - private static class VisorBinaryCollectMetadataJob - extends VisorJob { - /** */ - private static final long serialVersionUID = 0L; - - /** - * Create job with given argument. - * - * @param arg Task argument. - * @param debug Debug flag. - */ - private VisorBinaryCollectMetadataJob(VisorBinaryMetadataCollectorTaskArg arg, boolean debug) { - super(arg, debug); - } - - /** {@inheritDoc} */ - @Override protected VisorBinaryMetadataCollectorTaskResult run(VisorBinaryMetadataCollectorTaskArg arg) { - Marshaller marsh = ignite.configuration().getMarshaller(); - - IgniteBinary binary = marsh == null || marsh instanceof BinaryMarshaller ? ignite.binary() : null; - - return new VisorBinaryMetadataCollectorTaskResult(0L, VisorBinaryMetadata.list(binary)); - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorBinaryCollectMetadataJob.class, this); - } - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/binary/VisorBinaryMetadataCollectorTaskArg.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/binary/VisorBinaryMetadataCollectorTaskArg.java deleted file mode 100644 index 84ff96a7fefaf..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/binary/VisorBinaryMetadataCollectorTaskArg.java +++ /dev/null @@ -1,71 +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.binary; - -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.visor.VisorDataTransferObject; - -/** - * Arguments for {@link VisorBinaryMetadataCollectorTask}. - */ -public class VisorBinaryMetadataCollectorTaskArg extends VisorDataTransferObject { - /** */ - private static final long serialVersionUID = 0L; - - /** Time data was collected last time. */ - private long lastUpdate; - - /** - * Default constructor. - */ - public VisorBinaryMetadataCollectorTaskArg() { - // No-op. - } - - /** - * @param lastUpdate Time data was collected last time. - */ - public VisorBinaryMetadataCollectorTaskArg(long lastUpdate) { - this.lastUpdate = lastUpdate; - } - - /** - * @return Time data was collected last time. - */ - public long getMessage() { - return lastUpdate; - } - - /** {@inheritDoc} */ - @Override protected void writeExternalData(ObjectOutput out) throws IOException { - out.writeLong(lastUpdate); - } - - /** {@inheritDoc} */ - @Override protected void readExternalData(byte protoVer, ObjectInput in) throws IOException, ClassNotFoundException { - lastUpdate = in.readLong(); - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorBinaryMetadataCollectorTaskArg.class, this); - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/binary/VisorBinaryMetadataCollectorTaskResult.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/binary/VisorBinaryMetadataCollectorTaskResult.java deleted file mode 100644 index b31897c4fe416..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/binary/VisorBinaryMetadataCollectorTaskResult.java +++ /dev/null @@ -1,87 +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.binary; - -import java.io.IOException; -import java.io.ObjectInput; -import java.io.ObjectOutput; -import java.util.List; -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; - -/** - * Result for {@link VisorBinaryMetadataCollectorTask} - */ -public class VisorBinaryMetadataCollectorTaskResult extends VisorDataTransferObject { - /** */ - private static final long serialVersionUID = 0L; - - /** Last binary metadata update date. */ - private long lastUpdate; - - /** Remote data center IDs for which full state transfer was requested. */ - private List binary; - - /** - * Default constructor. - */ - public VisorBinaryMetadataCollectorTaskResult() { - // No-op. - } - - /** - * @param lastUpdate Last binary metadata update date. - * @param binary Remote data center IDs for which full state transfer was requested. - */ - public VisorBinaryMetadataCollectorTaskResult(Long lastUpdate, List binary) { - this.lastUpdate = lastUpdate; - this.binary = binary; - } - - /** - * @return Last binary metadata update date. - */ - public long getLastUpdate() { - return lastUpdate; - } - - /** - * @return Remote data center IDs for which full state transfer was requested. - */ - public List getBinary() { - return binary; - } - - /** {@inheritDoc} */ - @Override protected void writeExternalData(ObjectOutput out) throws IOException { - out.writeLong(lastUpdate); - U.writeCollection(out, binary); - } - - /** {@inheritDoc} */ - @Override protected void readExternalData(byte protoVer, ObjectInput in) throws IOException, ClassNotFoundException { - lastUpdate = in.readLong(); - binary = U.readList(in); - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorBinaryMetadataCollectorTaskResult.class, this); - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/binary/VisorBinaryMetadataField.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/binary/VisorBinaryMetadataField.java deleted file mode 100644 index 69c880c16768d..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/binary/VisorBinaryMetadataField.java +++ /dev/null @@ -1,101 +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.binary; - -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; -import org.jetbrains.annotations.Nullable; - -/** - * Binary object metadata field information. - */ -public class VisorBinaryMetadataField extends VisorDataTransferObject { - /** */ - private static final long serialVersionUID = 0L; - - /** Field name. */ - private String fieldName; - - /** Field type name. */ - private String fieldTypeName; - - /** Field id. */ - private Integer fieldId; - - /** - * Default constructor. - */ - public VisorBinaryMetadataField() { - // No-op. - } - - /** - * @param fieldName Field name. - * @param fieldTypeName Field type name. - * @param fieldId Field id. - */ - public VisorBinaryMetadataField(String fieldName, String fieldTypeName, Integer fieldId) { - this.fieldName = fieldName; - this.fieldTypeName = fieldTypeName; - this.fieldId = fieldId; - } - - /** - * @return Field name. - */ - public String getFieldName() { - return fieldName; - } - - /** - * @return Field type name. - */ - @Nullable public String getFieldTypeName() { - return fieldTypeName; - } - - /** - * @return Field id. - */ - public Integer getFieldId() { - return fieldId; - } - - /** {@inheritDoc} */ - @Override protected void writeExternalData(ObjectOutput out) throws IOException { - U.writeString(out, fieldName); - U.writeString(out, fieldTypeName); - out.writeObject(fieldId); - } - - /** {@inheritDoc} */ - @Override protected void readExternalData(byte protoVer, ObjectInput in) throws IOException, ClassNotFoundException { - fieldName = U.readString(in); - fieldTypeName = U.readString(in); - fieldId = (Integer)in.readObject(); - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorBinaryMetadataField.class, this); - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCache.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCache.java deleted file mode 100644 index 0d239546f2603..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCache.java +++ /dev/null @@ -1,341 +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.IOException; -import java.io.ObjectInput; -import java.io.ObjectOutput; -import org.apache.ignite.IgniteCache; -import org.apache.ignite.IgniteCheckedException; -import org.apache.ignite.cache.CacheMode; -import org.apache.ignite.cache.CachePeekMode; -import org.apache.ignite.configuration.CacheConfiguration; -import org.apache.ignite.internal.IgniteEx; -import org.apache.ignite.internal.processors.cache.GridCacheAdapter; -import org.apache.ignite.internal.processors.cache.GridCacheContext; -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 static org.apache.ignite.cache.CachePeekMode.BACKUP; -import static org.apache.ignite.cache.CachePeekMode.ONHEAP; -import static org.apache.ignite.cache.CachePeekMode.PRIMARY; - -/** - * Data transfer object for {@link IgniteCache}. - */ -public class VisorCache extends VisorDataTransferObject { - /** */ - private static final long serialVersionUID = 0L; - - /** */ - private static final CachePeekMode[] PEEK_ONHEAP_PRIMARY = - new CachePeekMode[] {ONHEAP, PRIMARY}; - - /** */ - private static final CachePeekMode[] PEEK_ONHEAP_BACKUP = - new CachePeekMode[] {ONHEAP, BACKUP}; - - /** Cache name. */ - private String name; - - /** Cache deployment ID. */ - private IgniteUuid dynamicDeploymentId; - - /** Cache mode. */ - private CacheMode mode; - - /** Cache size in bytes. */ - private long memorySize; - - /** Cache size in bytes. */ - private long indexesSize; - - /** Number of all entries in cache. */ - private long size; - - /** Number of all entries in near cache. */ - private int nearSize; - - /** Number of primary entries in cache. */ - private long primarySize; - - /** Number of backup entries in cache. */ - private long backupSize; - - /** Number of partitions. */ - private int partitions; - - /** Flag indicating that cache has near cache. */ - private boolean near; - - /** Cache metrics. */ - private VisorCacheMetrics metrics; - - /** Cache system state. */ - private boolean sys; - - /** Checks whether statistics collection is enabled in this cache. */ - private boolean statisticsEnabled; - - /** - * Create data transfer object for given cache. - */ - public VisorCache() { - // No-op. - } - - /** - * Create data transfer object for given cache. - * - * @param ca Internal cache. - * @param collectMetrics Collect cache metrics flag. - * @throws IgniteCheckedException If failed to create data transfer object. - */ - public VisorCache(IgniteEx ignite, GridCacheAdapter ca, boolean collectMetrics) throws IgniteCheckedException { - assert ca != null; - - GridCacheContext cctx = ca.context(); - CacheConfiguration cfg = ca.configuration(); - - name = ca.name(); - dynamicDeploymentId = cctx.dynamicDeploymentId(); - mode = cfg.getCacheMode(); - - primarySize = ca.localSizeLong(PEEK_ONHEAP_PRIMARY); - backupSize = ca.localSizeLong(PEEK_ONHEAP_BACKUP); - nearSize = ca.nearSize(); - size = primarySize + backupSize + nearSize; - - partitions = ca.affinity().partitions(); - near = cctx.isNear(); - - if (collectMetrics) - metrics = new VisorCacheMetrics(ignite, name); - - sys = ignite.context().cache().systemCache(name); - - statisticsEnabled = ca.clusterMetrics().isStatisticsEnabled(); - } - - /** - * @return Cache name. - */ - public String getName() { - return name; - } - - /** - * Sets new value for cache name. - * - * @param name New cache name. - */ - public void setName(String name) { - this.name = name; - } - - /** - * @return Dynamic deployment ID. - */ - public IgniteUuid getDynamicDeploymentId() { - return dynamicDeploymentId; - } - - /** - * @return Cache mode. - */ - public CacheMode getMode() { - return mode; - } - - /** - * @return Cache size in bytes. - */ - public long getMemorySize() { - return memorySize; - } - - /** - * @return Indexes size in bytes. - */ - public long getIndexesSize() { - return indexesSize; - } - - /** - * @return Number of all entries in cache. - */ - public long getSize() { - return size; - } - - /** - * @return Number of all entries in near cache. - */ - public int getNearSize() { - return nearSize; - } - - /** - * @return Number of backup entries in cache. - */ - public long getBackupSize() { - return backupSize; - } - - /** - * @return Number of primary entries in cache. - */ - public long getPrimarySize() { - return primarySize; - } - - /** - * @return Number of partitions. - */ - public int getPartitions() { - return partitions; - } - - /** - * @return Cache metrics. - */ - public VisorCacheMetrics getMetrics() { - return metrics; - } - - /** - * @param metrics Cache metrics. - */ - public void setMetrics(VisorCacheMetrics metrics) { - this.metrics = metrics; - } - - /** - * @return {@code true} if cache has near cache. - */ - public boolean isNear() { - return near; - } - - /** - * @return System cache flag. - */ - public boolean isSystem() { - return sys; - } - - /** - * @return Number of entries in cache in heap and off-heap. - */ - public long size() { - return size + (metrics != null ? metrics.getOffHeapEntriesCount() : 0L); - } - - /** - * @return Memory size allocated in off-heap. - */ - public long offHeapAllocatedSize() { - return metrics != null ? metrics.getOffHeapAllocatedSize() : 0L; - } - - /** - * @return Number of entries in heap memory. - */ - public long heapEntriesCount() { - return metrics != null ? metrics.getHeapEntriesCount() : 0L; - } - - /** - * @return Number of primary cache entries stored in off-heap memory. - */ - public long offHeapPrimaryEntriesCount() { - return metrics != null ? metrics.getOffHeapPrimaryEntriesCount() : 0L; - } - - /** - * @return Number of backup cache entries stored in off-heap memory. - */ - public long offHeapBackupEntriesCount() { - return metrics != null ? metrics.getOffHeapBackupEntriesCount() : 0L; - } - - /** - * @return Number of cache entries stored in off-heap memory. - */ - public long offHeapEntriesCount() { - return metrics != null ? metrics.getOffHeapEntriesCount() : 0L; - } - - /** - * @return Checks whether statistics collection is enabled in this cache. - */ - public boolean isStatisticsEnabled() { - return statisticsEnabled; - } - - /** {@inheritDoc} */ - @Override public byte getProtocolVersion() { - return V3; - } - - /** {@inheritDoc} */ - @Override protected void writeExternalData(ObjectOutput out) throws IOException { - U.writeString(out, name); - U.writeIgniteUuid(out, dynamicDeploymentId); - out.writeByte(CacheMode.toCode(mode)); - out.writeLong(memorySize); - out.writeLong(indexesSize); - out.writeLong(size); - out.writeInt(nearSize); - out.writeLong(primarySize); - out.writeLong(backupSize); - out.writeInt(partitions); - out.writeBoolean(near); - out.writeObject(metrics); - out.writeBoolean(sys); - out.writeBoolean(statisticsEnabled); - } - - /** {@inheritDoc} */ - @Override protected void readExternalData(byte protoVer, ObjectInput in) throws IOException, ClassNotFoundException { - name = U.readString(in); - dynamicDeploymentId = U.readIgniteUuid(in); - mode = CacheMode.fromCode(in.readByte()); - memorySize = in.readLong(); - indexesSize = in.readLong(); - size = in.readLong(); - nearSize = in.readInt(); - primarySize = in.readLong(); - backupSize = in.readLong(); - partitions = in.readInt(); - near = in.readBoolean(); - metrics = (VisorCacheMetrics)in.readObject(); - - sys = protoVer > V1 ? in.readBoolean() : metrics != null && metrics.isSystem(); - - if (protoVer > V2) - statisticsEnabled = in.readBoolean(); - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorCache.class, this); - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheAffinityNodeTask.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheAffinityNodeTask.java deleted file mode 100644 index 439b8d3edcd7b..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheAffinityNodeTask.java +++ /dev/null @@ -1,71 +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.util.UUID; -import org.apache.ignite.IgniteException; -import org.apache.ignite.cluster.ClusterNode; -import org.apache.ignite.internal.processors.task.GridInternal; -import org.apache.ignite.internal.processors.task.GridVisorManagementTask; -import org.apache.ignite.internal.util.typedef.internal.S; -import org.apache.ignite.internal.visor.VisorJob; -import org.apache.ignite.internal.visor.VisorOneNodeTask; -import org.jetbrains.annotations.Nullable; - -/** - * Task that will find affinity node for key. - */ -@GridInternal -@GridVisorManagementTask -public class VisorCacheAffinityNodeTask extends VisorOneNodeTask { - /** */ - private static final long serialVersionUID = 0L; - - /** {@inheritDoc} */ - @Override protected VisorCacheAffinityNodeJob job(VisorCacheAffinityNodeTaskArg arg) { - return new VisorCacheAffinityNodeJob(arg, debug); - } - - /** Job that will find affinity node for key. */ - private static class VisorCacheAffinityNodeJob extends VisorJob { - /** */ - private static final long serialVersionUID = 0L; - - /** - * @param arg Cache name and key to find affinity node. - * @param debug Debug flag. - */ - private VisorCacheAffinityNodeJob(VisorCacheAffinityNodeTaskArg arg, boolean debug) { - super(arg, debug); - } - - /** {@inheritDoc} */ - @Override protected UUID run(@Nullable VisorCacheAffinityNodeTaskArg arg) throws IgniteException { - assert arg != null; - - ClusterNode node = ignite.affinity(arg.getCacheName()).mapKeyToNode(arg.getKey()); - - return node != null ? node.id() : null; - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorCacheAffinityNodeJob.class, this); - } - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheAffinityNodeTaskArg.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheAffinityNodeTaskArg.java deleted file mode 100644 index ec057339f4b27..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheAffinityNodeTaskArg.java +++ /dev/null @@ -1,86 +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.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; - -/** - * Argument for {@link VisorCacheAffinityNodeTask}. - */ -public class VisorCacheAffinityNodeTaskArg extends VisorDataTransferObject { - /** */ - private static final long serialVersionUID = 0L; - - /** Cache name. */ - private String cacheName; - - /** Key to map to a node. */ - private Object key; - - /** - * Default constructor. - */ - public VisorCacheAffinityNodeTaskArg() { - // No-op. - } - - /** - * @param cacheName Cache name. - * @param key Object. - */ - public VisorCacheAffinityNodeTaskArg(String cacheName, Object key) { - this.cacheName = cacheName; - this.key = key; - } - - /** - * @return Cache name. - */ - public String getCacheName() { - return cacheName; - } - - /** - * @return Key to map to a node. - */ - public Object getKey() { - return key; - } - - /** {@inheritDoc} */ - @Override protected void writeExternalData(ObjectOutput out) throws IOException { - U.writeString(out, cacheName); - out.writeObject(key); - } - - /** {@inheritDoc} */ - @Override protected void readExternalData(byte protoVer, ObjectInput in) throws IOException, ClassNotFoundException { - cacheName = U.readString(in); - key = in.readObject(); - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorCacheAffinityNodeTaskArg.class, this); - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheAggregatedMetrics.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheAggregatedMetrics.java deleted file mode 100644 index 8bcb5de4ab61a..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheAggregatedMetrics.java +++ /dev/null @@ -1,628 +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.IOException; -import java.io.ObjectInput; -import java.io.ObjectOutput; -import java.util.Collection; -import java.util.HashMap; -import java.util.Map; -import java.util.UUID; -import org.apache.ignite.cache.CacheMode; -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 aggregated cache metrics. - */ -public class VisorCacheAggregatedMetrics extends VisorDataTransferObject { - /** */ - private static final long serialVersionUID = 0L; - - /** Cache name. */ - private String name; - - /** Cache mode. */ - private CacheMode mode; - - /** Cache system state. */ - private boolean sys; - - /** Node IDs with cache metrics. */ - private Map metrics = new HashMap<>(); - - /** Total number of entries in heap. */ - private transient Long totalHeapSize; - - /** Minimum number of entries in heap. */ - private transient Long minHeapSize; - - /** Average number of entries in heap. */ - private transient Double avgHeapSize; - - /** Maximum number of entries in heap. */ - private transient Long maxHeapSize; - - /** Total number of entries in off heap. */ - private transient Long totalOffHeapSize; - - /** Minimum number of entries in off heap. */ - private transient Long minOffHeapSize; - - /** Average number of entries in off heap. */ - private transient Double avgOffHeapSize; - - /** Maximum number of entries in off heap. */ - private transient Long maxOffHeapSize; - - /** Minimum hits of the owning cache. */ - private transient Long minHits; - - /** Average hits of the owning cache. */ - private transient Double avgHits; - - /** Maximum hits of the owning cache. */ - private transient Long maxHits; - - /** Minimum misses of the owning cache. */ - private transient Long minMisses; - - /** Average misses of the owning cache. */ - private transient Double avgMisses; - - /** Maximum misses of the owning cache. */ - private transient Long maxMisses; - - /** Minimum total number of reads of the owning cache. */ - private transient Long minReads; - - /** Average total number of reads of the owning cache. */ - private transient Double avgReads; - - /** Maximum total number of reads of the owning cache. */ - private transient Long maxReads; - - /** Minimum total number of writes of the owning cache. */ - private transient Long minWrites; - - /** Average total number of writes of the owning cache. */ - private transient Double avgWrites; - - /** Maximum total number of writes of the owning cache. */ - private transient Long maxWrites; - - /** Minimum execution time of query. */ - private transient Long minQryTime; - - /** Average execution time of query. */ - private transient Double avgQryTime; - - /** Maximum execution time of query. */ - private transient Long maxQryTime; - - /** Total execution time of query. */ - private transient Long totalQryTime; - - /** Number of executions. */ - private transient Integer execsQry; - - /** Total number of times a query execution failed. */ - private transient Integer failsQry; - - /** - * Default constructor. - */ - public VisorCacheAggregatedMetrics() { - // No-op. - } - - /** - * Create data transfer object for aggregated cache metrics. - * - * @param cm Source cache metrics. - */ - public VisorCacheAggregatedMetrics(VisorCacheMetrics cm) { - name = cm.getName(); - mode = cm.getMode(); - sys = cm.isSystem(); - } - - /** - * @return Cache name. - */ - public String getName() { - return name; - } - - /** @return Cache mode. */ - public CacheMode getMode() { - return mode; - } - - /** @return Cache system state. */ - public boolean isSystem() { - return sys; - } - - /** - * @return Nodes. - */ - public Collection getNodes() { - return metrics.keySet(); - } - - /** - * @return Total number of entries in heap. - */ - public long getTotalHeapSize() { - if (totalHeapSize == null) { - totalHeapSize = 0L; - - for (VisorCacheMetrics metric : metrics.values()) - totalHeapSize += metric.getHeapEntriesCount(); - } - - return totalHeapSize; - } - - /** - * @return Minimum number of entries in heap. - */ - public long getMinimumHeapSize() { - if (minHeapSize == null) { - minHeapSize = Long.MAX_VALUE; - - for (VisorCacheMetrics metric : metrics.values()) - minHeapSize = Math.min(minHeapSize, metric.getHeapEntriesCount()); - } - - return minHeapSize; - } - - /** - * @return Average number of entries in heap. - */ - public double getAverageHeapSize() { - if (avgHeapSize == null) { - avgHeapSize = 0.0d; - - for (VisorCacheMetrics metric : metrics.values()) - avgHeapSize += metric.getHeapEntriesCount(); - - avgHeapSize /= metrics.size(); - } - - return avgHeapSize; - } - - /** - * @return Maximum number of entries in heap. - */ - public long getMaximumHeapSize() { - if (maxHeapSize == null) { - maxHeapSize = Long.MIN_VALUE; - - for (VisorCacheMetrics metric : metrics.values()) - maxHeapSize = Math.max(maxHeapSize, metric.getHeapEntriesCount()); - } - - return maxHeapSize; - } - - /** - * @param metric Metrics to process. - * @return Off heap primary entries count. - */ - private long getOffHeapPrimaryEntriesCount(VisorCacheMetrics metric) { - return metric.getOffHeapPrimaryEntriesCount(); - } - - /** - * @return Total number of entries in off-heap. - */ - public long getTotalOffHeapSize() { - if (totalOffHeapSize == null) { - totalOffHeapSize = 0L; - - for (VisorCacheMetrics metric : metrics.values()) - totalOffHeapSize += metric.getOffHeapPrimaryEntriesCount(); - } - - return totalOffHeapSize; - } - - /** - * @return Minimum number of primary entries in off heap. - */ - public long getMinimumOffHeapPrimarySize() { - if (minOffHeapSize == null) { - minOffHeapSize = Long.MAX_VALUE; - - for (VisorCacheMetrics metric : metrics.values()) - minOffHeapSize = Math.min(minOffHeapSize, getOffHeapPrimaryEntriesCount(metric)); - } - - return minOffHeapSize; - } - - /** - * @return Average number of primary entries in off heap. - */ - public double getAverageOffHeapPrimarySize() { - if (avgOffHeapSize == null) { - avgOffHeapSize = 0.0d; - - for (VisorCacheMetrics metric : metrics.values()) - avgOffHeapSize += getOffHeapPrimaryEntriesCount(metric); - - avgOffHeapSize /= metrics.size(); - } - - return avgOffHeapSize; - } - - /** - * @return Maximum number of primary entries in off heap. - */ - public long getMaximumOffHeapPrimarySize() { - if (maxOffHeapSize == null) { - maxOffHeapSize = Long.MIN_VALUE; - - for (VisorCacheMetrics metric : metrics.values()) - maxOffHeapSize = Math.max(maxOffHeapSize, getOffHeapPrimaryEntriesCount(metric)); - } - - return maxOffHeapSize; - } - - /** - * @return Minimum hits of the owning cache. - */ - public long getMinimumHits() { - if (minHits == null) { - minHits = Long.MAX_VALUE; - - for (VisorCacheMetrics metric : metrics.values()) - minHits = Math.min(minHits, metric.getHits()); - } - - return minHits; - } - - /** - * @return Average hits of the owning cache. - */ - public double getAverageHits() { - if (avgHits == null) { - avgHits = 0.0d; - - for (VisorCacheMetrics metric : metrics.values()) - avgHits += metric.getHits(); - - avgHits /= metrics.size(); - } - - return avgHits; - } - - /** - * @return Maximum hits of the owning cache. - */ - public long getMaximumHits() { - if (maxHits == null) { - maxHits = Long.MIN_VALUE; - - for (VisorCacheMetrics metric : metrics.values()) - maxHits = Math.max(maxHits, metric.getHits()); - } - - return maxHits; - } - - /** - * @return Minimum misses of the owning cache. - */ - public long getMinimumMisses() { - if (minMisses == null) { - minMisses = Long.MAX_VALUE; - - for (VisorCacheMetrics metric : metrics.values()) - minMisses = Math.min(minMisses, metric.getMisses()); - } - - return minMisses; - } - - /** - * @return Average misses of the owning cache. - */ - public double getAverageMisses() { - if (avgMisses == null) { - avgMisses = 0.0d; - - for (VisorCacheMetrics metric : metrics.values()) - avgMisses += metric.getMisses(); - - avgMisses /= metrics.size(); - } - - return avgMisses; - } - - /** - * @return Maximum misses of the owning cache. - */ - public long getMaximumMisses() { - if (maxMisses == null) { - maxMisses = Long.MIN_VALUE; - - for (VisorCacheMetrics metric : metrics.values()) - maxMisses = Math.max(maxMisses, metric.getMisses()); - } - - return maxMisses; - } - - /** - * @return Minimum total number of reads of the owning cache. - */ - public long getMinimumReads() { - if (minReads == null) { - minReads = Long.MAX_VALUE; - - for (VisorCacheMetrics metric : metrics.values()) - minReads = Math.min(minReads, metric.getReads()); - } - - return minReads; - } - - /** - * @return Average total number of reads of the owning cache. - */ - public double getAverageReads() { - if (avgReads == null) { - avgReads = 0.0d; - - for (VisorCacheMetrics metric : metrics.values()) - avgReads += metric.getReads(); - - avgReads /= metrics.size(); - } - - return avgReads; - } - - /** - * @return Maximum total number of reads of the owning cache. - */ - public long getMaximumReads() { - if (maxReads == null) { - maxReads = Long.MIN_VALUE; - - for (VisorCacheMetrics metric : metrics.values()) - maxReads = Math.max(maxReads, metric.getReads()); - } - - return maxReads; - } - - /** - * @return Minimum total number of writes of the owning cache. - */ - public long getMinimumWrites() { - if (minWrites == null) { - minWrites = Long.MAX_VALUE; - - for (VisorCacheMetrics metric : metrics.values()) - minWrites = Math.min(minWrites, metric.getWrites()); - } - - return minWrites; - } - - /** - * @return Average total number of writes of the owning cache. - */ - public double getAverageWrites() { - if (avgWrites == null) { - avgWrites = 0.0d; - - for (VisorCacheMetrics metric : metrics.values()) - avgWrites += metric.getWrites(); - - avgWrites /= metrics.size(); - } - - return avgWrites; - } - - /** - * @return Maximum total number of writes of the owning cache. - */ - public long getMaximumWrites() { - if (maxWrites == null) { - maxWrites = Long.MIN_VALUE; - - for (VisorCacheMetrics metric : metrics.values()) - maxWrites = Math.max(maxWrites, metric.getWrites()); - } - - return maxWrites; - } - - /** - * @return Minimum execution time of query. - */ - public long getMinimumQueryTime() { - if (minQryTime == null) { - minQryTime = Long.MAX_VALUE; - - for (VisorCacheMetrics metric : metrics.values()) - minQryTime = Math.min(minQryTime, metric.getQueryMetrics().getMinimumTime()); - } - - return minQryTime; - } - - /** - * @return Average execution time of query. - */ - public double getAverageQueryTime() { - if (avgQryTime == null) { - avgQryTime = 0.0d; - - for (VisorCacheMetrics metric : metrics.values()) - avgQryTime += metric.getQueryMetrics().getAverageTime(); - - avgQryTime /= metrics.size(); - } - - return avgQryTime; - } - - /** - * @return Maximum execution time of query. - */ - public long getMaximumQueryTime() { - if (maxQryTime == null) { - maxQryTime = Long.MIN_VALUE; - - for (VisorCacheMetrics metric : metrics.values()) - maxQryTime = Math.max(maxQryTime, metric.getQueryMetrics().getMaximumTime()); - } - - return maxQryTime; - } - - /** - * @return Total execution time of query. - */ - public long getTotalQueryTime() { - if (totalQryTime == null) - totalQryTime = (long)(getAverageQueryTime() * getQueryExecutions()); - - return totalQryTime; - } - - /** - * @return Number of executions. - */ - public int getQueryExecutions() { - if (execsQry == null) { - execsQry = 0; - - for (VisorCacheMetrics metric : metrics.values()) - execsQry += metric.getQueryMetrics().getExecutions(); - } - - return execsQry; - } - - /** - * @return Total number of times a query execution failed. - */ - public int getQueryFailures() { - if (failsQry == null) { - failsQry = 0; - - for (VisorCacheMetrics metric : metrics.values()) - failsQry += metric.getQueryMetrics().getFailures(); - } - - return failsQry; - } - - /** - * @return Map of Node IDs to cache metrics. - */ - public Map getMetrics() { - return metrics; - } - - /** {@inheritDoc} */ - @Override protected void writeExternalData(ObjectOutput out) throws IOException { - U.writeString(out, name); - out.writeByte(CacheMode.toCode(mode)); - out.writeBoolean(sys); - U.writeMap(out, metrics); - out.writeObject(minHeapSize); - out.writeObject(avgHeapSize); - out.writeObject(maxHeapSize); - out.writeObject(minOffHeapSize); - out.writeObject(avgOffHeapSize); - out.writeObject(maxOffHeapSize); - out.writeObject(minHits); - out.writeObject(avgHits); - out.writeObject(maxHits); - out.writeObject(minMisses); - out.writeObject(avgMisses); - out.writeObject(maxMisses); - out.writeObject(minReads); - out.writeObject(avgReads); - out.writeObject(maxReads); - out.writeObject(minWrites); - out.writeObject(avgWrites); - out.writeObject(maxWrites); - out.writeObject(minQryTime); - out.writeObject(avgQryTime); - out.writeObject(maxQryTime); - out.writeObject(totalQryTime); - out.writeObject(execsQry); - out.writeObject(failsQry); - } - - /** {@inheritDoc} */ - @Override protected void readExternalData(byte protoVer, ObjectInput in) throws IOException, ClassNotFoundException { - name = U.readString(in); - mode = CacheMode.fromCode(in.readByte()); - sys = in.readBoolean(); - metrics = U.readMap(in); - minHeapSize = (Long)in.readObject(); - avgHeapSize = (Double)in.readObject(); - maxHeapSize = (Long)in.readObject(); - minOffHeapSize = (Long)in.readObject(); - avgOffHeapSize = (Double)in.readObject(); - maxOffHeapSize = (Long)in.readObject(); - minHits = (Long)in.readObject(); - avgHits = (Double)in.readObject(); - maxHits = (Long)in.readObject(); - minMisses = (Long)in.readObject(); - avgMisses = (Double)in.readObject(); - maxMisses = (Long)in.readObject(); - minReads = (Long)in.readObject(); - avgReads = (Double)in.readObject(); - maxReads = (Long)in.readObject(); - minWrites = (Long)in.readObject(); - avgWrites = (Double)in.readObject(); - maxWrites = (Long)in.readObject(); - minQryTime = (Long)in.readObject(); - avgQryTime = (Double)in.readObject(); - maxQryTime = (Long)in.readObject(); - totalQryTime = (Long)in.readObject(); - execsQry = (Integer)in.readObject(); - failsQry = (Integer)in.readObject(); - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorCacheAggregatedMetrics.class, this); - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheClearTask.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheClearTask.java deleted file mode 100644 index 68142b97aad60..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheClearTask.java +++ /dev/null @@ -1,146 +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 org.apache.ignite.IgniteCache; -import org.apache.ignite.cache.CachePeekMode; -import org.apache.ignite.compute.ComputeJobContext; -import org.apache.ignite.internal.processors.task.GridInternal; -import org.apache.ignite.internal.processors.task.GridVisorManagementTask; -import org.apache.ignite.internal.util.typedef.internal.S; -import org.apache.ignite.internal.visor.VisorJob; -import org.apache.ignite.internal.visor.VisorOneNodeTask; -import org.apache.ignite.lang.IgniteFuture; -import org.apache.ignite.lang.IgniteInClosure; -import org.apache.ignite.resources.JobContextResource; - -/** - * Task that clears specified caches on specified node. - */ -@GridInternal -@GridVisorManagementTask -public class VisorCacheClearTask extends VisorOneNodeTask { - /** */ - private static final long serialVersionUID = 0L; - - /** {@inheritDoc} */ - @Override protected VisorCacheClearJob job(VisorCacheClearTaskArg arg) { - return new VisorCacheClearJob(arg, debug); - } - - /** - * Job that clear specified caches. - */ - private static class VisorCacheClearJob extends VisorJob { - /** */ - private static final long serialVersionUID = 0L; - - /** */ - private final IgniteInClosure lsnr; - - /** */ - private IgniteFuture[] futs; - - /** */ - @JobContextResource - private ComputeJobContext jobCtx; - - /** - * Create job. - * - * @param arg Task argument. - * @param debug Debug flag. - */ - private VisorCacheClearJob(VisorCacheClearTaskArg arg, boolean debug) { - super(arg, debug); - - lsnr = new IgniteInClosure() { - /** */ - private static final long serialVersionUID = 0L; - - @Override public void apply(IgniteFuture f) { - assert futs[0].isDone(); - assert futs[1] == null || futs[1].isDone(); - assert futs[2] == null || futs[2].isDone(); - - jobCtx.callcc(); - } - }; - } - - /** - * @param fut Future to listen. - * @return {@code true} If future was not completed and this job should holdCC. - */ - private boolean callAsync(IgniteFuture fut) { - if (fut.isDone()) - return false; - - jobCtx.holdcc(); - - fut.listen(lsnr); - - return true; - } - - /** {@inheritDoc} */ - @Override protected VisorCacheClearTaskResult run(final VisorCacheClearTaskArg arg) { - if (futs == null) - futs = new IgniteFuture[3]; - - if (futs[0] == null || futs[1] == null || futs[2] == null) { - String cacheName = arg.getCacheName(); - - IgniteCache cache = ignite.cache(cacheName); - - if (cache == null) - throw new IllegalStateException("Failed to find cache for name: " + cacheName); - - if (futs[0] == null) { - futs[0] = cache.sizeLongAsync(CachePeekMode.PRIMARY); - - if (callAsync(futs[0])) - return null; - } - - if (futs[1] == null) { - futs[1] = cache.clearAsync(); - - if (callAsync(futs[1])) - return null; - } - - if (futs[2] == null) { - futs[2] = cache.sizeLongAsync(CachePeekMode.PRIMARY); - - if (callAsync(futs[2])) - return null; - } - } - - assert futs[0].isDone() && futs[1].isDone() && futs[2].isDone(); - - return new VisorCacheClearTaskResult(futs[0].get(), futs[2].get()); - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorCacheClearJob.class, this); - } - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheClearTaskArg.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheClearTaskArg.java deleted file mode 100644 index ade2e12684599..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheClearTaskArg.java +++ /dev/null @@ -1,72 +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.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; - -/** - * Argument for {@link VisorCacheClearTask}. - */ -public class VisorCacheClearTaskArg extends VisorDataTransferObject { - /** */ - private static final long serialVersionUID = 0L; - - /** Cache name. */ - private String cacheName; - - /** - * Default constructor. - */ - public VisorCacheClearTaskArg() { - // No-op. - } - - /** - * @param cacheName Cache name. - */ - public VisorCacheClearTaskArg(String cacheName) { - this.cacheName = cacheName; - } - - /** - * @return Cache name. - */ - public String getCacheName() { - return cacheName; - } - - /** {@inheritDoc} */ - @Override protected void writeExternalData(ObjectOutput out) throws IOException { - U.writeString(out, cacheName); - } - - /** {@inheritDoc} */ - @Override protected void readExternalData(byte protoVer, ObjectInput in) throws IOException, ClassNotFoundException { - cacheName = U.readString(in); - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorCacheClearTaskArg.class, this); - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheClearTaskResult.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheClearTaskResult.java deleted file mode 100644 index c7249f75eb2ff..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheClearTaskResult.java +++ /dev/null @@ -1,85 +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.IOException; -import java.io.ObjectInput; -import java.io.ObjectOutput; -import org.apache.ignite.internal.util.typedef.internal.S; -import org.apache.ignite.internal.visor.VisorDataTransferObject; - -/** - * Result for {@link VisorCacheClearTask}. - */ -public class VisorCacheClearTaskResult extends VisorDataTransferObject { - /** */ - private static final long serialVersionUID = 0L; - - /** Cache size before clearing. */ - private long sizeBefore; - - /** Cache size after clearing. */ - private long sizeAfter; - - /** - * Default constructor. - */ - public VisorCacheClearTaskResult() { - // No-op. - } - - /** - * @param sizeBefore Cache size before clearing. - * @param sizeAfter Cache size after clearing. - */ - public VisorCacheClearTaskResult(long sizeBefore, long sizeAfter) { - this.sizeBefore = sizeBefore; - this.sizeAfter = sizeAfter; - } - - /** - * @return Cache size before clearing. - */ - public long getSizeBefore() { - return sizeBefore; - } - - /** - * @return Cache size after clearing. - */ - public long getSizeAfter() { - return sizeAfter; - } - - /** {@inheritDoc} */ - @Override protected void writeExternalData(ObjectOutput out) throws IOException { - out.writeLong(sizeBefore); - out.writeLong(sizeAfter); - } - - /** {@inheritDoc} */ - @Override protected void readExternalData(byte protoVer, ObjectInput in) throws IOException, ClassNotFoundException { - sizeBefore = in.readLong(); - sizeAfter = in.readLong(); - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorCacheClearTaskResult.class, this); - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheLoadTask.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheLoadTask.java deleted file mode 100644 index 5d1bccd06f3bf..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheLoadTask.java +++ /dev/null @@ -1,102 +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.util.Map; -import java.util.Set; -import java.util.concurrent.TimeUnit; -import javax.cache.expiry.CreatedExpiryPolicy; -import javax.cache.expiry.Duration; -import javax.cache.expiry.ExpiryPolicy; -import org.apache.ignite.IgniteCache; -import org.apache.ignite.cache.CachePeekMode; -import org.apache.ignite.internal.processors.task.GridInternal; -import org.apache.ignite.internal.processors.task.GridVisorManagementTask; -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; - -/** - * Task to loads caches. - */ -@GridInternal -@GridVisorManagementTask -public class VisorCacheLoadTask extends - VisorOneNodeTask> { - /** */ - private static final long serialVersionUID = 0L; - - /** {@inheritDoc} */ - @Override protected VisorCachesLoadJob job(VisorCacheLoadTaskArg arg) { - return new VisorCachesLoadJob(arg, debug); - } - - /** Job that load caches. */ - private static class VisorCachesLoadJob extends - VisorJob> { - /** */ - private static final long serialVersionUID = 0L; - - /** - * @param arg Cache names, ttl and loader arguments. - * @param debug Debug flag. - */ - private VisorCachesLoadJob(VisorCacheLoadTaskArg arg, boolean debug) { - super(arg, debug); - } - - /** {@inheritDoc} */ - @Override protected Map run(VisorCacheLoadTaskArg arg) { - Set cacheNames = arg.getCacheNames(); - long ttl = arg.getTtl(); - Object[] ldrArgs = arg.getLoaderArguments(); - - assert cacheNames != null && !cacheNames.isEmpty(); - - Map res = U.newHashMap(cacheNames.size()); - - ExpiryPolicy plc = null; - - for (String cacheName : cacheNames) { - IgniteCache cache = ignite.cache(cacheName); - - if (cache == null) - throw new IllegalStateException("Failed to find cache for name: " + cacheName); - - if (ttl > 0) { - if (plc == null) - plc = new CreatedExpiryPolicy(new Duration(TimeUnit.MILLISECONDS, ttl)); - - cache = cache.withExpiryPolicy(plc); - } - - cache.loadCache(null, ldrArgs); - - res.put(cacheName, cache.size(CachePeekMode.PRIMARY)); - } - - return res; - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorCachesLoadJob.class, this); - } - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheLoadTaskArg.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheLoadTaskArg.java deleted file mode 100644 index b5da99322de64..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheLoadTaskArg.java +++ /dev/null @@ -1,101 +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.IOException; -import java.io.ObjectInput; -import java.io.ObjectOutput; -import java.util.Set; -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; - -/** - * Arguments for {@link VisorCacheLoadTask}. - */ -public class VisorCacheLoadTaskArg extends VisorDataTransferObject { - /** */ - private static final long serialVersionUID = 0L; - - /** Cache names to load data. */ - private Set cacheNames; - - /** Duration a Cache Entry should exist be before it expires after being modified. */ - private long ttl; - - /** Optional user arguments to be passed into CacheStore.loadCache(IgniteBiInClosure, Object...) method. */ - private Object[] ldrArgs; - - /** - * Default constructor. - */ - public VisorCacheLoadTaskArg() { - // No-op. - } - - /** - * @param cacheNames Cache names to load data. - * @param ttl Duration a Cache Entry should exist be before it expires after being modified. - * @param ldrArgs Optional user arguments to be passed into CacheStore.loadCache(IgniteBiInClosure, Object...) method. - */ - public VisorCacheLoadTaskArg(Set cacheNames, long ttl, Object[] ldrArgs) { - this.cacheNames = cacheNames; - this.ttl = ttl; - this.ldrArgs = ldrArgs; - } - - /** - * @return Cache names to load data. - */ - public Set getCacheNames() { - return cacheNames; - } - - /** - * @return Duration a Cache Entry should exist be before it expires after being modified. - */ - public long getTtl() { - return ttl; - } - - /** - * @return Optional user arguments to be passed into CacheStore.loadCache(IgniteBiInClosure, Object...) method. - */ - public Object[] getLoaderArguments() { - return ldrArgs; - } - - /** {@inheritDoc} */ - @Override protected void writeExternalData(ObjectOutput out) throws IOException { - U.writeCollection(out, cacheNames); - out.writeLong(ttl); - U.writeArray(out, ldrArgs); - } - - /** {@inheritDoc} */ - @Override protected void readExternalData(byte protoVer, ObjectInput in) throws IOException, ClassNotFoundException { - cacheNames = U.readSet(in); - ttl = in.readLong(); - ldrArgs = U.readArray(in); - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorCacheLoadTaskArg.class, this); - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheLostPartitionsTask.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheLostPartitionsTask.java deleted file mode 100644 index daa4af7bec8ae..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheLostPartitionsTask.java +++ /dev/null @@ -1,88 +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.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import org.apache.ignite.internal.processors.cache.IgniteInternalCache; -import org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtPartitionTopology; -import org.apache.ignite.internal.processors.task.GridInternal; -import org.apache.ignite.internal.processors.task.GridVisorManagementTask; -import org.apache.ignite.internal.util.typedef.internal.S; -import org.apache.ignite.internal.visor.VisorJob; -import org.apache.ignite.internal.visor.VisorOneNodeTask; - -/** - * Collect list of lost partitions. - */ -@GridInternal -@GridVisorManagementTask -public class VisorCacheLostPartitionsTask - extends VisorOneNodeTask { - /** */ - private static final long serialVersionUID = 0L; - - /** {@inheritDoc} */ - @Override protected VisorCacheLostPartitionsJob job(VisorCacheLostPartitionsTaskArg arg) { - return new VisorCacheLostPartitionsJob(arg, debug); - } - - /** - * Job that collect list of lost partitions. - */ - private static class VisorCacheLostPartitionsJob - extends VisorJob { - /** */ - private static final long serialVersionUID = 0L; - - /** - * @param arg Object with list of cache names to collect lost partitions. - * @param debug Debug flag. - */ - private VisorCacheLostPartitionsJob(VisorCacheLostPartitionsTaskArg arg, boolean debug) { - super(arg, debug); - } - - /** {@inheritDoc} */ - @Override protected VisorCacheLostPartitionsTaskResult run(VisorCacheLostPartitionsTaskArg arg) { - Map> res = new HashMap<>(); - - for (String cacheName: arg.getCacheNames()) { - IgniteInternalCache cache = ignite.cachex(cacheName); - - if (cache != null) { - GridDhtPartitionTopology top = cache.context().topology(); - - List lostPartitions = new ArrayList<>(top.lostPartitions()); - - if (!lostPartitions.isEmpty()) - res.put(cacheName, lostPartitions); - } - } - - return new VisorCacheLostPartitionsTaskResult(res); - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorCacheLostPartitionsJob.class, this); - } - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheLostPartitionsTaskArg.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheLostPartitionsTaskArg.java deleted file mode 100644 index a937ce483b4ea..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheLostPartitionsTaskArg.java +++ /dev/null @@ -1,81 +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.IOException; -import java.io.ObjectInput; -import java.io.ObjectOutput; -import java.util.List; -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; - -/** - * Argument for {@link VisorCacheLostPartitionsTask}. - */ -public class VisorCacheLostPartitionsTaskArg extends VisorDataTransferObject { - /** */ - private static final long serialVersionUID = 0L; - - /** List of cache names. */ - private List cacheNames; - - /** Created for toString method because Collection can't be printed. */ - private String modifiedCaches; - - /** - * Default constructor. - */ - public VisorCacheLostPartitionsTaskArg() { - // No-op. - } - - /** - * @param cacheNames List of cache names. - */ - public VisorCacheLostPartitionsTaskArg(List cacheNames) { - this.cacheNames = cacheNames; - - if (cacheNames != null) - modifiedCaches = cacheNames.toString(); - } - - /** - * @return List of cache names. - */ - public List getCacheNames() { - return cacheNames; - } - - /** {@inheritDoc} */ - @Override protected void writeExternalData(ObjectOutput out) throws IOException { - U.writeCollection(out, cacheNames); - U.writeString(out, modifiedCaches); - } - - /** {@inheritDoc} */ - @Override protected void readExternalData(byte protoVer, ObjectInput in) throws IOException, ClassNotFoundException { - cacheNames = U.readList(in); - modifiedCaches = U.readString(in); - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorCacheLostPartitionsTaskArg.class, this); - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheLostPartitionsTaskResult.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheLostPartitionsTaskResult.java deleted file mode 100644 index b9a0e6b13ad81..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheLostPartitionsTaskResult.java +++ /dev/null @@ -1,74 +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.IOException; -import java.io.ObjectInput; -import java.io.ObjectOutput; -import java.util.List; -import java.util.Map; -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; - -/** - * Result for {@link VisorCacheLostPartitionsTask}. - */ -public class VisorCacheLostPartitionsTaskResult extends VisorDataTransferObject { - /** */ - private static final long serialVersionUID = 0L; - - /** List of lost partitions by caches. */ - private Map> lostPartitions; - - /** - * Default constructor. - */ - public VisorCacheLostPartitionsTaskResult() { - // No-op. - } - - /** - * @param lostPartitions List of lost partitions by caches. - */ - public VisorCacheLostPartitionsTaskResult(Map> lostPartitions) { - this.lostPartitions = lostPartitions; - } - - /** - * @return List of lost partitions by caches. - */ - public Map> getLostPartitions() { - return lostPartitions; - } - - /** {@inheritDoc} */ - @Override protected void writeExternalData(ObjectOutput out) throws IOException { - U.writeMap(out, lostPartitions); - } - - /** {@inheritDoc} */ - @Override protected void readExternalData(byte protoVer, ObjectInput in) throws IOException, ClassNotFoundException { - lostPartitions = U.readMap(in); - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorCacheLostPartitionsTaskResult.class, this); - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheMetadataTask.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheMetadataTask.java deleted file mode 100644 index 033087599e76d..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheMetadataTask.java +++ /dev/null @@ -1,87 +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 org.apache.ignite.IgniteCheckedException; -import org.apache.ignite.IgniteException; -import org.apache.ignite.internal.processors.cache.IgniteInternalCache; -import org.apache.ignite.internal.processors.cache.query.GridCacheSqlMetadata; -import org.apache.ignite.internal.processors.task.GridInternal; -import org.apache.ignite.internal.util.typedef.F; -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 static org.apache.ignite.internal.visor.util.VisorTaskUtils.escapeName; - -/** - * Task to get cache SQL metadata. - */ -@GridInternal -public class VisorCacheMetadataTask extends VisorOneNodeTask { - /** */ - private static final long serialVersionUID = 0L; - - /** {@inheritDoc} */ - @Override protected VisorCacheMetadataJob job(VisorCacheMetadataTaskArg arg) { - return new VisorCacheMetadataJob(arg, debug); - } - - /** - * Job to get cache SQL metadata. - */ - private static class VisorCacheMetadataJob extends VisorJob { - /** */ - private static final long serialVersionUID = 0L; - - /** - * @param arg Cache name to take metadata. - * @param debug Debug flag. - */ - private VisorCacheMetadataJob(VisorCacheMetadataTaskArg arg, boolean debug) { - super(arg, debug); - } - - /** {@inheritDoc} */ - @Override protected VisorCacheSqlMetadata run(VisorCacheMetadataTaskArg arg) { - try { - IgniteInternalCache cache = ignite.cachex(arg.getCacheName()); - - if (cache != null) { - GridCacheSqlMetadata meta = F.first(cache.context().queries().sqlMetadata()); - - if (meta != null) - return new VisorCacheSqlMetadata(meta); - - return null; - } - - throw new IgniteException("Cache not found: " + escapeName(arg.getCacheName())); - } - catch (IgniteCheckedException e) { - throw U.convertException(e); - } - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorCacheMetadataJob.class, this); - } - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheMetadataTaskArg.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheMetadataTaskArg.java deleted file mode 100644 index 99ee350b63f2f..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheMetadataTaskArg.java +++ /dev/null @@ -1,72 +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.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; - -/** - * Argument for {@link VisorCacheMetadataTask}. - */ -public class VisorCacheMetadataTaskArg extends VisorDataTransferObject { - /** */ - private static final long serialVersionUID = 0L; - - /** Cache name. */ - private String cacheName; - - /** - * Default constructor. - */ - public VisorCacheMetadataTaskArg() { - // No-op. - } - - /** - * @param cacheName Cache name. - */ - public VisorCacheMetadataTaskArg(String cacheName) { - this.cacheName = cacheName; - } - - /** - * @return Cache name. - */ - public String getCacheName() { - return cacheName; - } - - /** {@inheritDoc} */ - @Override protected void writeExternalData(ObjectOutput out) throws IOException { - U.writeString(out, cacheName); - } - - /** {@inheritDoc} */ - @Override protected void readExternalData(byte protoVer, ObjectInput in) throws IOException, ClassNotFoundException { - cacheName = U.readString(in); - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorCacheMetadataTaskArg.class, this); - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheMetrics.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheMetrics.java deleted file mode 100644 index 378de7a5e9832..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheMetrics.java +++ /dev/null @@ -1,812 +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.IOException; -import java.io.ObjectInput; -import java.io.ObjectOutput; -import org.apache.ignite.IgniteCache; -import org.apache.ignite.cache.CacheMetrics; -import org.apache.ignite.cache.CacheMode; -import org.apache.ignite.internal.IgniteEx; -import org.apache.ignite.internal.processors.cache.GridCacheProcessor; -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.internal.visor.query.VisorQueryMetrics; - -/** - * Data transfer object for {@link CacheMetrics}. - */ -public class VisorCacheMetrics extends VisorDataTransferObject { - /** */ - private static final long serialVersionUID = 0L; - - /** */ - private static final float MICROSECONDS_IN_SECOND = 1_000_000; - - /** Cache name. */ - private String name; - - /** Cache mode. */ - private CacheMode mode; - - /** Cache system state. */ - private boolean sys; - - /** Number of non-{@code null} values in the cache. */ - private int size; - - /** Gets number of keys in the cache, possibly with {@code null} values. */ - private int keySize; - - /** Number of non-{@code null} values in the cache as a long value. */ - private long cacheSize; - - /** Total number of reads of the owning entity (either cache or entry). */ - private long reads; - - /** The mean time to execute gets. */ - private float avgReadTime; - - /** Total number of writes of the owning entity (either cache or entry). */ - private long writes; - - /** Total number of hits for the owning entity (either cache or entry). */ - private long hits; - - /** Total number of misses for the owning entity (either cache or entry). */ - private long misses; - - /** Total number of transaction commits. */ - private long txCommits; - - /** The mean time to execute tx commit. */ - private float avgTxCommitTime; - - /** Total number of transaction rollbacks. */ - private long txRollbacks; - - /** The mean time to execute tx rollbacks. */ - private float avgTxRollbackTime; - - /** The total number of puts to the cache. */ - private long puts; - - /** The mean time to execute puts. */ - private float avgPutTime; - - /** The total number of removals from the cache. */ - private long removals; - - /** The mean time to execute removes. */ - private float avgRemovalTime; - - /** The total number of evictions from the cache. */ - private long evictions; - - /** Reads per second. */ - private int readsPerSec; - - /** Puts per second. */ - private int putsPerSec; - - /** Removes per second. */ - private int removalsPerSec; - - /** Commits per second. */ - private int commitsPerSec; - - /** Rollbacks per second. */ - private int rollbacksPerSec; - - /** Current size of evict queue used to batch up evictions. */ - private int dhtEvictQueueCurrSize; - - /** Gets transaction per-thread map size. */ - private int txThreadMapSize; - - /** Transaction per-Xid map size. */ - private int txXidMapSize; - - /** Committed transaction queue size. */ - private int txCommitQueueSize; - - /** Prepared transaction queue size. */ - private int txPrepareQueueSize; - - /** Start version counts map size. */ - private int txStartVerCountsSize; - - /** Number of cached committed transaction IDs. */ - private int txCommittedVersionsSize; - - /** Number of cached rolled back transaction IDs. */ - private int txRolledbackVersionsSize; - - /** DHT thread map size */ - private int txDhtThreadMapSize; - - /** Transaction DHT per-Xid map size. */ - private int txDhtXidMapSize; - - /** Committed DHT transaction queue size. */ - private int txDhtCommitQueueSize; - - /** Prepared DHT transaction queue size. */ - private int txDhtPrepareQueueSize; - - /** DHT start version counts map size. */ - private int txDhtStartVerCountsSize; - - /** Number of cached committed DHT transaction IDs. */ - private int txDhtCommittedVersionsSize; - - /** Number of cached rolled back DHT transaction IDs. */ - private int txDhtRolledbackVersionsSize; - - /** Number of cache entries stored in heap memory. */ - private long heapEntriesCnt; - - /** Memory size allocated in off-heap. */ - private long offHeapAllocatedSize; - - /** Number of cache entries stored in off-heap memory. */ - private long offHeapEntriesCnt; - - /** Number of primary cache entries stored in off-heap memory. */ - private long offHeapPrimaryEntriesCnt; - - /** Total number of partitions on current node. */ - private int totalPartsCnt; - - /** Number of already rebalanced keys. */ - private long rebalancedKeys; - - /** Number estimated to rebalance keys. */ - private long estimatedRebalancingKeys; - - /** Number of currently rebalancing partitions on current node. */ - private int rebalancingPartsCnt; - - /** Estimated number of keys to be rebalanced on current node. */ - private long keysToRebalanceLeft; - - /** Estimated rebalancing speed in keys. */ - private long rebalancingKeysRate; - - /** Estimated rebalancing speed in bytes. */ - private long rebalancingBytesRate; - - /** Gets query metrics for cache. */ - private VisorQueryMetrics qryMetrics; - - /** - * Calculate rate of metric per second. - * - * @param meanTime Metric mean time. - * @return Metric per second. - */ - private static int perSecond(float meanTime) { - return (meanTime > 0) ? (int)(MICROSECONDS_IN_SECOND / meanTime) : 0; - } - - /** - * Default constructor. - */ - public VisorCacheMetrics() { - // No-op. - } - - /** - * Create data transfer object for given cache metrics. - * - * @param ignite Ignite. - * @param cacheName Cache name. - */ - public VisorCacheMetrics(IgniteEx ignite, String cacheName) { - GridCacheProcessor cacheProcessor = ignite.context().cache(); - - IgniteCache c = cacheProcessor.jcache(cacheName); - - name = cacheName; - mode = cacheProcessor.cacheMode(cacheName); - sys = cacheProcessor.systemCache(cacheName); - - CacheMetrics m = c.localMetrics(); - - size = m.getSize(); - keySize = m.getKeySize(); - - cacheSize = m.getCacheSize(); - - reads = m.getCacheGets(); - writes = m.getCachePuts() + m.getCacheRemovals(); - hits = m.getCacheHits(); - misses = m.getCacheMisses(); - - txCommits = m.getCacheTxCommits(); - txRollbacks = m.getCacheTxRollbacks(); - - avgTxCommitTime = m.getAverageTxCommitTime(); - avgTxRollbackTime = m.getAverageTxRollbackTime(); - - puts = m.getCachePuts(); - removals = m.getCacheRemovals(); - evictions = m.getCacheEvictions(); - - avgReadTime = m.getAverageGetTime(); - avgPutTime = m.getAveragePutTime(); - avgRemovalTime = m.getAverageRemoveTime(); - - readsPerSec = perSecond(m.getAverageGetTime()); - putsPerSec = perSecond(m.getAveragePutTime()); - removalsPerSec = perSecond(m.getAverageRemoveTime()); - commitsPerSec = perSecond(m.getAverageTxCommitTime()); - rollbacksPerSec = perSecond(m.getAverageTxRollbackTime()); - - dhtEvictQueueCurrSize = m.getDhtEvictQueueCurrentSize(); - txThreadMapSize = m.getTxThreadMapSize(); - txXidMapSize = m.getTxXidMapSize(); - txCommitQueueSize = m.getTxCommitQueueSize(); - txPrepareQueueSize = m.getTxPrepareQueueSize(); - txStartVerCountsSize = m.getTxStartVersionCountsSize(); - txCommittedVersionsSize = m.getTxCommittedVersionsSize(); - txRolledbackVersionsSize = m.getTxRolledbackVersionsSize(); - txDhtThreadMapSize = m.getTxDhtThreadMapSize(); - txDhtXidMapSize = m.getTxDhtXidMapSize(); - txDhtCommitQueueSize = m.getTxDhtCommitQueueSize(); - txDhtPrepareQueueSize = m.getTxDhtPrepareQueueSize(); - txDhtStartVerCountsSize = m.getTxDhtStartVersionCountsSize(); - txDhtCommittedVersionsSize = m.getTxDhtCommittedVersionsSize(); - txDhtRolledbackVersionsSize = m.getTxDhtRolledbackVersionsSize(); - - heapEntriesCnt = m.getHeapEntriesCount(); - offHeapAllocatedSize = m.getOffHeapAllocatedSize(); - offHeapEntriesCnt = m.getOffHeapEntriesCount(); - offHeapPrimaryEntriesCnt = m.getOffHeapPrimaryEntriesCount(); - - totalPartsCnt = m.getTotalPartitionsCount(); - rebalancedKeys = m.getRebalancedKeys(); - estimatedRebalancingKeys = m.getEstimatedRebalancingKeys(); - rebalancingPartsCnt = m.getRebalancingPartitionsCount(); - keysToRebalanceLeft = m.getKeysToRebalanceLeft(); - rebalancingKeysRate = m.getRebalancingKeysRate(); - rebalancingBytesRate = m.getRebalancingBytesRate(); - - qryMetrics = new VisorQueryMetrics(c.queryMetrics()); - } - - /** - * @return Cache name. - */ - public String getName() { - return name; - } - - /** - * Sets cache name. - * - * @param name New value for cache name. - */ - public void setName(String name) { - this.name = name; - } - - /** - * @return Cache mode. - */ - public CacheMode getMode() { - return mode; - } - - /** - * @return Cache system state. - */ - public boolean isSystem() { - return sys; - } - - /** - * @return Total number of reads of the owning entity (either cache or entry). - */ - public long getReads() { - return reads; - } - - /** - * @return The mean time to execute gets - */ - public float getAvgReadTime() { - return avgReadTime; - } - - /** - * @return Total number of writes of the owning entity (either cache or entry). - */ - public long getWrites() { - return writes; - } - - /** - * @return Total number of hits for the owning entity (either cache or entry). - */ - public long getHits() { - return hits; - } - - /** - * @return Total number of misses for the owning entity (either cache or entry). - */ - public long getMisses() { - return misses; - } - - /** - * @return Total number of transaction commits. - */ - public long getTxCommits() { - return txCommits; - } - - /** - * @return avgTxCommitTime - */ - public float getAvgTxCommitTime() { - return avgTxCommitTime; - } - - /** - * @return The mean time to execute tx rollbacks. - */ - public float getAvgTxRollbackTime() { - return avgTxRollbackTime; - } - - /** - * @return The total number of puts to the cache. - */ - public long getPuts() { - return puts; - } - - /** - * @return The mean time to execute puts. - */ - public float getAvgPutTime() { - return avgPutTime; - } - - /** - * @return The total number of removals from the cache. - */ - public long getRemovals() { - return removals; - } - - /** - * @return The mean time to execute removes. - */ - public float getAvgRemovalTime() { - return avgRemovalTime; - } - - /** - * @return The total number of evictions from the cache. - */ - public long getEvictions() { - return evictions; - } - - /** - * @return Total number of transaction rollbacks. - */ - public long getTxRollbacks() { - return txRollbacks; - } - - /** - * @return Reads per second. - */ - public int getReadsPerSecond() { - return readsPerSec; - } - - /** - * @return Puts per second. - */ - public int getPutsPerSecond() { - return putsPerSec; - } - - /** - * @return Removes per second. - */ - public int getRemovalsPerSecond() { - return removalsPerSec; - } - - /** - * @return Commits per second. - */ - public int getCommitsPerSecond() { - return commitsPerSec; - } - - /** - * @return Rollbacks per second. - */ - public int getRollbacksPerSecond() { - return rollbacksPerSec; - } - - /** - * @return Number of non-{@code null} values in the cache. - */ - public int getSize() { - return size; - } - - /** - * @return Gets number of keys in the cache, possibly with {@code null} values. - */ - public int getKeySize() { - return keySize; - } - - /** - * @return Number of non-{@code null} values in the cache as a long value. - */ - public long getCacheSize() { - return cacheSize; - } - - /** - * @return Gets query metrics for cache. - */ - public VisorQueryMetrics getQueryMetrics() { - return qryMetrics; - } - - /** - * @return Current size of evict queue used to batch up evictions. - */ - public int getDhtEvictQueueCurrentSize() { - return dhtEvictQueueCurrSize; - } - - /** - * @return Gets transaction per-thread map size. - */ - public int getTxThreadMapSize() { - return txThreadMapSize; - } - - /** - * @return Transaction per-Xid map size. - */ - public int getTxXidMapSize() { - return txXidMapSize; - } - - /** - * @return Committed transaction queue size. - */ - public int getTxCommitQueueSize() { - return txCommitQueueSize; - } - - /** - * @return Prepared transaction queue size. - */ - public int getTxPrepareQueueSize() { - return txPrepareQueueSize; - } - - /** - * @return Start version counts map size. - */ - public int getTxStartVersionCountsSize() { - return txStartVerCountsSize; - } - - /** - * @return Number of cached committed transaction IDs. - */ - public int getTxCommittedVersionsSize() { - return txCommittedVersionsSize; - } - - /** - * @return Number of cached rolled back transaction IDs. - */ - public int getTxRolledbackVersionsSize() { - return txRolledbackVersionsSize; - } - - /** - * @return DHT thread map size - */ - public int getTxDhtThreadMapSize() { - return txDhtThreadMapSize; - } - - /** - * @return Transaction DHT per-Xid map size. - */ - public int getTxDhtXidMapSize() { - return txDhtXidMapSize; - } - - /** - * @return Committed DHT transaction queue size. - */ - public int getTxDhtCommitQueueSize() { - return txDhtCommitQueueSize; - } - - /** - * @return Prepared DHT transaction queue size. - */ - public int getTxDhtPrepareQueueSize() { - return txDhtPrepareQueueSize; - } - - /** - * @return DHT start version counts map size. - */ - public int getTxDhtStartVersionCountsSize() { - return txDhtStartVerCountsSize; - } - - /** - * @return Number of cached committed DHT transaction IDs. - */ - public int getTxDhtCommittedVersionsSize() { - return txDhtCommittedVersionsSize; - } - - /** - * @return Number of cached rolled back DHT transaction IDs. - */ - public int getTxDhtRolledbackVersionsSize() { - return txDhtRolledbackVersionsSize; - } - - /** - * @return Number of entries in heap memory. - */ - public long getHeapEntriesCount() { - return heapEntriesCnt; - } - - /** - * @return Memory size allocated in off-heap. - */ - public long getOffHeapAllocatedSize() { - return offHeapAllocatedSize; - } - - /** - * @return Number of cache entries stored in off-heap memory. - */ - public long getOffHeapEntriesCount() { - return offHeapEntriesCnt; - } - - /** - * @return Number of primary cache entries stored in off-heap memory. - */ - public long getOffHeapPrimaryEntriesCount() { - return offHeapPrimaryEntriesCnt; - } - - /** - * @return Number of backup cache entries stored in off-heap memory. - */ - public long getOffHeapBackupEntriesCount() { - return offHeapEntriesCnt - offHeapPrimaryEntriesCnt; - } - - /** - * @return Total number of partitions on current node. - */ - public int getTotalPartitionsCount() { - return totalPartsCnt; - } - - /** - * @return Number of already rebalanced keys. - */ - public long getRebalancedKeys() { - return rebalancedKeys; - } - - /** - * @return Number estimated to rebalance keys. - */ - public long getEstimatedRebalancingKeys() { - return estimatedRebalancingKeys; - } - - /** - * @return Number of currently rebalancing partitions on current node. - */ - public int getRebalancingPartitionsCount() { - return rebalancingPartsCnt; - } - - /** - * @return Estimated number of keys to be rebalanced on current node. - */ - public long getKeysToRebalanceLeft() { - return keysToRebalanceLeft; - } - - /** - * @return Estimated rebalancing speed in keys. - */ - public long getRebalancingKeysRate() { - return rebalancingKeysRate; - } - - /** - * @return Estimated rebalancing speed in bytes. - */ - public long getRebalancingBytesRate() { - return rebalancingBytesRate; - } - - /** {@inheritDoc} */ - @Override public byte getProtocolVersion() { - return V2; - } - - /** {@inheritDoc} */ - @Override protected void writeExternalData(ObjectOutput out) throws IOException { - U.writeString(out, name); - out.writeByte(CacheMode.toCode(mode)); - - out.writeBoolean(sys); - out.writeInt(size); - out.writeInt(keySize); - out.writeLong(reads); - out.writeFloat(avgReadTime); - out.writeLong(writes); - out.writeLong(hits); - out.writeLong(misses); - out.writeLong(txCommits); - out.writeFloat(avgTxCommitTime); - out.writeLong(txRollbacks); - out.writeFloat(avgTxRollbackTime); - out.writeLong(puts); - out.writeFloat(avgPutTime); - out.writeLong(removals); - out.writeFloat(avgRemovalTime); - out.writeLong(evictions); - out.writeInt(readsPerSec); - out.writeInt(putsPerSec); - out.writeInt(removalsPerSec); - out.writeInt(commitsPerSec); - out.writeInt(rollbacksPerSec); - out.writeInt(dhtEvictQueueCurrSize); - - out.writeInt(txThreadMapSize); - out.writeInt(txXidMapSize); - out.writeInt(txCommitQueueSize); - out.writeInt(txPrepareQueueSize); - out.writeInt(txStartVerCountsSize); - out.writeInt(txCommittedVersionsSize); - out.writeInt(txRolledbackVersionsSize); - out.writeInt(txDhtThreadMapSize); - out.writeInt(txDhtXidMapSize); - out.writeInt(txDhtCommitQueueSize); - out.writeInt(txDhtPrepareQueueSize); - out.writeInt(txDhtStartVerCountsSize); - out.writeInt(txDhtCommittedVersionsSize); - out.writeInt(txDhtRolledbackVersionsSize); - - out.writeLong(heapEntriesCnt); - out.writeLong(offHeapAllocatedSize); - out.writeLong(offHeapEntriesCnt); - out.writeLong(offHeapPrimaryEntriesCnt); - - out.writeInt(totalPartsCnt); - out.writeInt(rebalancingPartsCnt); - out.writeLong(keysToRebalanceLeft); - out.writeLong(rebalancingKeysRate); - out.writeLong(rebalancingBytesRate); - - out.writeObject(qryMetrics); - - out.writeLong(cacheSize); - - out.writeLong(rebalancedKeys); - out.writeLong(estimatedRebalancingKeys); - } - - /** {@inheritDoc} */ - @Override protected void readExternalData(byte protoVer, ObjectInput in) throws IOException, ClassNotFoundException { - name = U.readString(in); - mode = CacheMode.fromCode(in.readByte()); - sys = in.readBoolean(); - size = in.readInt(); - keySize = in.readInt(); - reads = in.readLong(); - avgReadTime = in.readFloat(); - writes = in.readLong(); - hits = in.readLong(); - misses = in.readLong(); - txCommits = in.readLong(); - avgTxCommitTime = in.readFloat(); - txRollbacks = in.readLong(); - avgTxRollbackTime = in.readFloat(); - puts = in.readLong(); - avgPutTime = in.readFloat(); - removals = in.readLong(); - avgRemovalTime = in.readFloat(); - evictions = in.readLong(); - readsPerSec = in.readInt(); - putsPerSec = in.readInt(); - removalsPerSec = in.readInt(); - commitsPerSec = in.readInt(); - rollbacksPerSec = in.readInt(); - dhtEvictQueueCurrSize = in.readInt(); - - txThreadMapSize = in.readInt(); - txXidMapSize = in.readInt(); - txCommitQueueSize = in.readInt(); - txPrepareQueueSize = in.readInt(); - txStartVerCountsSize = in.readInt(); - txCommittedVersionsSize = in.readInt(); - txRolledbackVersionsSize = in.readInt(); - txDhtThreadMapSize = in.readInt(); - txDhtXidMapSize = in.readInt(); - txDhtCommitQueueSize = in.readInt(); - txDhtPrepareQueueSize = in.readInt(); - txDhtStartVerCountsSize = in.readInt(); - txDhtCommittedVersionsSize = in.readInt(); - txDhtRolledbackVersionsSize = in.readInt(); - - heapEntriesCnt = in.readLong(); - offHeapAllocatedSize = in.readLong(); - offHeapEntriesCnt = in.readLong(); - offHeapPrimaryEntriesCnt = in.readLong(); - - totalPartsCnt = in.readInt(); - rebalancingPartsCnt = in.readInt(); - keysToRebalanceLeft = in.readLong(); - rebalancingKeysRate = in.readLong(); - rebalancingBytesRate = in.readLong(); - - qryMetrics = (VisorQueryMetrics)in.readObject(); - - if (in.available() > 0) - cacheSize = in.readLong(); - - if (protoVer > V1) { - rebalancedKeys = in.readLong(); - estimatedRebalancingKeys = in.readLong(); - } - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorCacheMetrics.class, this); - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheMetricsCollectorTask.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheMetricsCollectorTask.java deleted file mode 100644 index 4c18ba3c78247..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheMetricsCollectorTask.java +++ /dev/null @@ -1,136 +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.util.ArrayList; -import java.util.Collection; -import java.util.List; -import java.util.Map; -import org.apache.ignite.compute.ComputeJobResult; -import org.apache.ignite.internal.processors.cache.GridCacheContext; -import org.apache.ignite.internal.processors.cache.GridCacheProcessor; -import org.apache.ignite.internal.processors.cache.IgniteCacheProxy; -import org.apache.ignite.internal.processors.task.GridInternal; -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.VisorMultiNodeTask; -import org.apache.ignite.internal.visor.util.VisorTaskUtils; -import org.jetbrains.annotations.Nullable; - -/** - * Task that collect cache metrics from all nodes. - */ -@GridInternal -public class VisorCacheMetricsCollectorTask extends VisorMultiNodeTask, Collection> { - /** */ - private static final long serialVersionUID = 0L; - - /** {@inheritDoc} */ - @Override protected VisorCacheMetricsCollectorJob job(VisorCacheMetricsCollectorTaskArg arg) { - return new VisorCacheMetricsCollectorJob(arg, debug); - } - - /** {@inheritDoc} */ - @Nullable @Override protected Iterable reduce0(List results) { - Map grpAggrMetrics = U.newHashMap(results.size()); - - for (ComputeJobResult res : results) { - if (res.getException() == null) { - Collection cms = res.getData(); - - for (VisorCacheMetrics cm : cms) { - VisorCacheAggregatedMetrics am = grpAggrMetrics.get(cm.getName()); - - if (am == null) { - am = new VisorCacheAggregatedMetrics(cm); - - grpAggrMetrics.put(cm.getName(), am); - } - - am.getMetrics().put(res.getNode().id(), cm); - } - } - } - - // Create serializable result. - return new ArrayList<>(grpAggrMetrics.values()); - } - - /** - * Job that collect cache metrics from node. - */ - private static class VisorCacheMetricsCollectorJob - extends VisorJob> { - - /** */ - private static final long serialVersionUID = 0L; - - /** - * Create job with given argument. - * - * @param arg Whether to collect metrics for all caches or for specified cache name only. - * @param debug Debug flag. - */ - private VisorCacheMetricsCollectorJob(VisorCacheMetricsCollectorTaskArg arg, boolean debug) { - super(arg, debug); - } - - /** {@inheritDoc} */ - @Override protected Collection run(final VisorCacheMetricsCollectorTaskArg arg) { - assert arg != null; - - boolean showSysCaches = arg.isShowSystemCaches(); - - Collection cacheNames = arg.getCacheNames(); - - assert cacheNames != null; - - GridCacheProcessor cacheProcessor = ignite.context().cache(); - - Collection> caches = cacheProcessor.jcaches(); - - Collection res = new ArrayList<>(caches.size()); - - boolean allCaches = cacheNames.isEmpty(); - - for (IgniteCacheProxy ca : caches) { - String cacheName = ca.getName(); - - if (!VisorTaskUtils.isRestartingCache(ignite, cacheName)) { - GridCacheContext ctx = ca.context(); - - if (ctx.started() && (ctx.affinityNode() || ctx.isNear())) { - VisorCacheMetrics cm = new VisorCacheMetrics(ignite, cacheName); - - if ((allCaches || cacheNames.contains(cacheName)) && (showSysCaches || !cm.isSystem())) - res.add(cm); - } - } - } - - return res; - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorCacheMetricsCollectorJob.class, this); - } - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheMetricsCollectorTaskArg.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheMetricsCollectorTaskArg.java deleted file mode 100644 index 9529ab4d0a346..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheMetricsCollectorTaskArg.java +++ /dev/null @@ -1,87 +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.IOException; -import java.io.ObjectInput; -import java.io.ObjectOutput; -import java.util.List; -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; - -/** - * Cache start arguments. - */ -public class VisorCacheMetricsCollectorTaskArg extends VisorDataTransferObject { - /** */ - private static final long serialVersionUID = 0L; - - /** Collect metrics for system caches. */ - private boolean showSysCaches; - - /** Cache names to collect metrics. */ - private List cacheNames; - - /** - * Default constructor. - */ - public VisorCacheMetricsCollectorTaskArg() { - // No-op. - } - - /** - * @param showSysCaches Collect metrics for system caches. - * @param cacheNames Cache names to collect metrics. - */ - public VisorCacheMetricsCollectorTaskArg(boolean showSysCaches, List cacheNames) { - this.showSysCaches = showSysCaches; - this.cacheNames = cacheNames; - } - - /** - * @return Collect metrics for system caches - */ - public boolean isShowSystemCaches() { - return showSysCaches; - } - - /** - * @return Cache names to collect metrics - */ - public List getCacheNames() { - return cacheNames; - } - - /** {@inheritDoc} */ - @Override protected void writeExternalData(ObjectOutput out) throws IOException { - out.writeBoolean(showSysCaches); - U.writeCollection(out, cacheNames); - } - - /** {@inheritDoc} */ - @Override protected void readExternalData(byte protoVer, ObjectInput in) throws IOException, ClassNotFoundException { - showSysCaches = in.readBoolean(); - cacheNames = U.readList(in); - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorCacheMetricsCollectorTaskArg.class, this); - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheModifyTask.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheModifyTask.java deleted file mode 100644 index f68efa8622e1b..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheModifyTask.java +++ /dev/null @@ -1,115 +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.util.UUID; -import org.apache.ignite.IgniteCache; -import org.apache.ignite.cluster.ClusterNode; -import org.apache.ignite.internal.processors.task.GridInternal; -import org.apache.ignite.internal.processors.task.GridVisorManagementTask; -import org.apache.ignite.internal.util.typedef.internal.S; -import org.apache.ignite.internal.visor.VisorJob; -import org.apache.ignite.internal.visor.VisorOneNodeTask; -import org.apache.ignite.internal.visor.query.VisorQueryUtils; -import org.apache.ignite.internal.visor.util.VisorTaskUtils; - -/** - * Task that modify value in specified cache. - */ -@GridInternal -@GridVisorManagementTask -public class VisorCacheModifyTask extends VisorOneNodeTask { - /** */ - private static final long serialVersionUID = 0L; - - /** {@inheritDoc} */ - @Override protected VisorCacheModifyJob job(VisorCacheModifyTaskArg arg) { - return new VisorCacheModifyJob(arg, debug); - } - - /** - * Job that modify value in specified cache. - */ - private static class VisorCacheModifyJob extends VisorJob { - /** */ - private static final long serialVersionUID = 0L; - - /** - * Create job. - * - * @param arg Task argument. - * @param debug Debug flag. - */ - private VisorCacheModifyJob(VisorCacheModifyTaskArg arg, boolean debug) { - super(arg, debug); - } - - /** {@inheritDoc} */ - @Override protected VisorCacheModifyTaskResult run(final VisorCacheModifyTaskArg arg) { - assert arg != null; - - VisorModifyCacheMode mode = arg.getMode(); - String cacheName = arg.getCacheName(); - Object key = arg.getKey(); - - assert mode != null; - assert cacheName != null; - assert key != null; - - IgniteCache cache = ignite.cache(cacheName); - - if (cache == null) - throw new IllegalArgumentException("Failed to find cache with specified name [cacheName=" + arg.getCacheName() + "]"); - - ClusterNode node = ignite.affinity(cacheName).mapKeyToNode(key); - - UUID nid = node != null ? node.id() : null; - - switch (mode) { - case PUT: - Object old = cache.get(key); - - cache.put(key, arg.getValue()); - - return new VisorCacheModifyTaskResult(nid, VisorTaskUtils.compactClass(old), - VisorQueryUtils.convertValue(old)); - - case GET: - Object val = cache.get(key); - - return new VisorCacheModifyTaskResult(nid, VisorTaskUtils.compactClass(val), - VisorQueryUtils.convertValue(val)); - - case REMOVE: - Object rmv = cache.get(key); - - cache.remove(key); - - return new VisorCacheModifyTaskResult(nid, VisorTaskUtils.compactClass(rmv), - VisorQueryUtils.convertValue(rmv)); - } - - return new VisorCacheModifyTaskResult(nid, null, null); - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorCacheModifyJob.class, this); - } - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheModifyTaskArg.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheModifyTaskArg.java deleted file mode 100644 index 3948a2f086672..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheModifyTaskArg.java +++ /dev/null @@ -1,120 +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.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; - -/** - * Argument for {@link VisorCacheModifyTask}. - */ -public class VisorCacheModifyTaskArg extends VisorDataTransferObject { - /** */ - private static final long serialVersionUID = 0L; - - /** Cache name. */ - private String cacheName; - - /** Modification mode. */ - private VisorModifyCacheMode mode; - - /** Specified key. */ - private Object key; - - /** Specified value. */ - private Object val; - - /** Created for toString method because Object can't be printed. */ - private String modifiedValues; - - /** - * Default constructor. - */ - public VisorCacheModifyTaskArg() { - // No-op. - } - - /** - * @param cacheName Cache name. - * @param mode Modification mode. - * @param key Specified key. - * @param val Specified value. - */ - public VisorCacheModifyTaskArg(String cacheName, VisorModifyCacheMode mode, Object key, Object val) { - this.cacheName = cacheName; - this.mode = mode; - this.key = key; - this.val = val; - this.modifiedValues = "[Key=" + key + ", Value=" + val + "]"; - } - - /** - * @return Cache name. - */ - public String getCacheName() { - return cacheName; - } - - /** - * @return Modification mode. - */ - public VisorModifyCacheMode getMode() { - return mode; - } - - /** - * @return Specified key. - */ - public Object getKey() { - return key; - } - - /** - * @return Specified value. - */ - public Object getValue() { - return val; - } - - /** {@inheritDoc} */ - @Override protected void writeExternalData(ObjectOutput out) throws IOException { - U.writeString(out, cacheName); - U.writeEnum(out, mode); - out.writeObject(key); - out.writeObject(val); - U.writeString(out, modifiedValues); - } - - /** {@inheritDoc} */ - @Override protected void readExternalData(byte protoVer, ObjectInput in) throws IOException, ClassNotFoundException { - cacheName = U.readString(in); - mode = VisorModifyCacheMode.fromOrdinal(in.readByte()); - key = in.readObject(); - val = in.readObject(); - modifiedValues = U.readString(in); - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorCacheModifyTaskArg.class, this); - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheModifyTaskResult.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheModifyTaskResult.java deleted file mode 100644 index 8d0152af57631..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheModifyTaskResult.java +++ /dev/null @@ -1,101 +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.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.VisorDataTransferObject; - -/** - * Result for {@link VisorCacheModifyTask}. - */ -public class VisorCacheModifyTaskResult extends VisorDataTransferObject { - /** */ - private static final long serialVersionUID = 0L; - - /** Node ID where modified data contained. */ - private UUID affinityNode; - - /** Result type name. */ - private String resType; - - /** Value for specified key or number of modified rows. */ - private Object res; - - /** - * Default constructor. - */ - public VisorCacheModifyTaskResult() { - // No-op. - } - - /** - * @param affinityNode Node ID where modified data contained. - * @param resType Result type name. - * @param res Value for specified key or number of modified rows. - */ - public VisorCacheModifyTaskResult(UUID affinityNode, String resType, Object res) { - this.affinityNode = affinityNode; - this.resType = resType; - this.res = res; - } - - /** - * @return Node ID where modified data contained. - */ - public UUID getAffinityNode() { - return affinityNode; - } - - /** - * @return Result type name. - */ - public String getResultType() { - return resType; - } - - /** - * @return Value for specified key or number of modified rows. - */ - public Object getResult() { - return res; - } - - /** {@inheritDoc} */ - @Override protected void writeExternalData(ObjectOutput out) throws IOException { - U.writeUuid(out, affinityNode); - U.writeString(out, resType); - out.writeObject(res); - } - - /** {@inheritDoc} */ - @Override protected void readExternalData(byte protoVer, ObjectInput in) throws IOException, ClassNotFoundException { - affinityNode = U.readUuid(in); - resType = U.readString(in); - res = in.readObject(); - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorCacheModifyTaskResult.class, this); - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheNamesCollectorTask.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheNamesCollectorTask.java deleted file mode 100644 index 7d934d14339e0..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheNamesCollectorTask.java +++ /dev/null @@ -1,90 +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.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; - -import org.apache.ignite.internal.processors.cache.DynamicCacheDescriptor; -import org.apache.ignite.internal.processors.cache.GridCacheProcessor; -import org.apache.ignite.internal.processors.task.GridInternal; -import org.apache.ignite.internal.util.typedef.F; -import org.apache.ignite.internal.util.typedef.internal.S; -import org.apache.ignite.internal.visor.VisorJob; -import org.apache.ignite.internal.visor.VisorOneNodeTask; -import org.apache.ignite.lang.IgniteUuid; - -/** - * Task that collect cache names and deployment IDs. - */ -@GridInternal -public class VisorCacheNamesCollectorTask extends VisorOneNodeTask { - /** */ - private static final long serialVersionUID = 0L; - - /** {@inheritDoc} */ - @Override protected VisorCacheNamesCollectorJob job(Void arg) { - return new VisorCacheNamesCollectorJob(arg, debug); - } - - /** - * Job that collect cache names and deployment IDs. - */ - private static class VisorCacheNamesCollectorJob extends VisorJob { - /** */ - private static final long serialVersionUID = 0L; - - /** - * Create job. - * - * @param arg Task argument. - * @param debug Debug flag. - */ - private VisorCacheNamesCollectorJob(Void arg, boolean debug) { - super(arg, debug); - } - - /** {@inheritDoc} */ - @Override protected VisorCacheNamesCollectorTaskResult run(Void arg) { - GridCacheProcessor cacheProc = ignite.context().cache(); - - Map caches = new HashMap<>(); - Set groups = new HashSet<>(); - - for (Map.Entry item : cacheProc.cacheDescriptors().entrySet()) { - DynamicCacheDescriptor cd = item.getValue(); - - caches.put(item.getKey(), cd.deploymentId()); - - String grp = cd.groupDescriptor().groupName(); - - if (!F.isEmpty(grp)) - groups.add(grp); - } - - return new VisorCacheNamesCollectorTaskResult(caches, groups); - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorCacheNamesCollectorJob.class, this); - } - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheNamesCollectorTaskResult.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheNamesCollectorTaskResult.java deleted file mode 100644 index a2e0908f3e9ff..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheNamesCollectorTaskResult.java +++ /dev/null @@ -1,88 +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.IOException; -import java.io.ObjectInput; -import java.io.ObjectOutput; -import java.util.Map; -import java.util.Set; -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; - -/** - * Result for {@link VisorCacheNamesCollectorTask}. - */ -public class VisorCacheNamesCollectorTaskResult extends VisorDataTransferObject { - /** */ - private static final long serialVersionUID = 0L; - - /** Cache names and deployment IDs. */ - private Map caches; - - /** Cache groups. */ - private Set groups; - - /** - * Default constructor. - */ - public VisorCacheNamesCollectorTaskResult() { - // No-op. - } - - /** - * @param caches Cache names and deployment IDs. - */ - public VisorCacheNamesCollectorTaskResult(Map caches, Set groups) { - this.caches = caches; - this.groups = groups; - } - - /** - * @return Value for specified key or number of modified rows.. - */ - public Map getCaches() { - return caches; - } - - /** - * @return Value for specified key or number of modified rows.. - */ - public Set getGroups() { - return groups; - } - - /** {@inheritDoc} */ - @Override protected void writeExternalData(ObjectOutput out) throws IOException { - U.writeMap(out, caches); - U.writeCollection(out, groups); - } - - /** {@inheritDoc} */ - @Override protected void readExternalData(byte protoVer, ObjectInput in) throws IOException, ClassNotFoundException { - caches = U.readMap(in); - groups = U.readSet(in); - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorCacheNamesCollectorTaskResult.class, this); - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheNodesTask.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheNodesTask.java deleted file mode 100644 index a8ed0a4fd13b6..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheNodesTask.java +++ /dev/null @@ -1,76 +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.util.ArrayList; -import java.util.Collection; -import java.util.UUID; -import org.apache.ignite.cluster.ClusterNode; -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.VisorOneNodeTask; - -/** - * Task that returns collection of cache data nodes IDs. - */ -@GridInternal -public class VisorCacheNodesTask extends VisorOneNodeTask> { - /** */ - private static final long serialVersionUID = 0L; - - /** {@inheritDoc} */ - @Override protected VisorCacheNodesJob job(VisorCacheNodesTaskArg arg) { - return new VisorCacheNodesJob(arg, debug); - } - - /** - * Job that collects cluster group for specified cache. - */ - private static class VisorCacheNodesJob extends VisorJob> { - /** */ - private static final long serialVersionUID = 0L; - - /** - * Create job. - * - * @param cacheName Cache name to clear. - * @param debug Debug flag. - */ - private VisorCacheNodesJob(VisorCacheNodesTaskArg cacheName, boolean debug) { - super(cacheName, debug); - } - - /** {@inheritDoc} */ - @Override protected Collection run(VisorCacheNodesTaskArg arg) { - Collection nodes = ignite.cluster().forDataNodes(arg.getCacheName()).nodes(); - - Collection res = new ArrayList<>(nodes.size()); - - for (ClusterNode node : nodes) - res.add(node.id()); - - return res; - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorCacheNodesJob.class, this); - } - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheNodesTaskArg.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheNodesTaskArg.java deleted file mode 100644 index 29e00e5b96df0..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheNodesTaskArg.java +++ /dev/null @@ -1,72 +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.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; - -/** - * Argument for {@link VisorCacheNodesTask}. - */ -public class VisorCacheNodesTaskArg extends VisorDataTransferObject { - /** */ - private static final long serialVersionUID = 0L; - - /** Cache name. */ - private String cacheName; - - /** - * Default constructor. - */ - public VisorCacheNodesTaskArg() { - // No-op. - } - - /** - * @param cacheName Cache name. - */ - public VisorCacheNodesTaskArg(String cacheName) { - this.cacheName = cacheName; - } - - /** - * @return Cache name. - */ - public String getCacheName() { - return cacheName; - } - - /** {@inheritDoc} */ - @Override protected void writeExternalData(ObjectOutput out) throws IOException { - U.writeString(out, cacheName); - } - - /** {@inheritDoc} */ - @Override protected void readExternalData(byte protoVer, ObjectInput in) throws IOException, ClassNotFoundException { - cacheName = U.readString(in); - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorCacheNodesTaskArg.class, this); - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCachePartitions.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCachePartitions.java deleted file mode 100644 index 99feb23177a7b..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCachePartitions.java +++ /dev/null @@ -1,100 +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.IOException; -import java.io.ObjectInput; -import java.io.ObjectOutput; -import java.util.HashMap; -import java.util.Map; -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 information about cache partitions. - */ -public class VisorCachePartitions extends VisorDataTransferObject { - /** */ - private static final long serialVersionUID = 0L; - - /** */ - private Map primary; - - /** */ - private Map backup; - - /** - * Default constructor. - */ - public VisorCachePartitions() { - primary = new HashMap<>(); - backup = new HashMap<>(); - } - - /** - * Add primary partition descriptor. - * - * @param partId Partition id. - * @param cnt Number of primary keys in partition. - */ - public void addPrimary(int partId, long cnt) { - primary.put(partId, cnt); - } - - /** - * Add backup partition descriptor. - * - * @param partId Partition id. - * @param cnt Number of backup keys in partition. - */ - public void addBackup(int partId, long cnt) { - backup.put(partId, cnt); - } - - /** - * @return Get list of primary partitions. - */ - public Map getPrimary() { - return primary; - } - - /** - * @return Get list of backup partitions. - */ - public Map getBackup() { - return backup; - } - - /** {@inheritDoc} */ - @Override protected void writeExternalData(ObjectOutput out) throws IOException { - U.writeMap(out, primary); - U.writeMap(out, backup); - } - - /** {@inheritDoc} */ - @Override protected void readExternalData(byte protoVer, ObjectInput in) throws IOException, ClassNotFoundException { - primary = U.readMap(in); - backup = U.readMap(in); - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorCachePartitions.class, this); - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCachePartitionsTask.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCachePartitionsTask.java deleted file mode 100644 index 11ae18de754f8..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCachePartitionsTask.java +++ /dev/null @@ -1,147 +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.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.UUID; -import org.apache.ignite.IgniteException; -import org.apache.ignite.cache.CacheMode; -import org.apache.ignite.compute.ComputeJobResult; -import org.apache.ignite.configuration.CacheConfiguration; -import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion; -import org.apache.ignite.internal.processors.cache.GridCacheAdapter; -import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtCacheAdapter; -import org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtLocalPartition; -import org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtPartitionState; -import org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtPartitionTopology; -import org.apache.ignite.internal.processors.cache.distributed.near.GridNearCacheAdapter; -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.internal.visor.util.VisorTaskUtils; -import org.jetbrains.annotations.Nullable; - -import static org.apache.ignite.internal.visor.util.VisorTaskUtils.escapeName; -import static org.apache.ignite.internal.visor.util.VisorTaskUtils.log; - -/** - * Task that collect keys distribution in partitions. - */ -@GridInternal -public class VisorCachePartitionsTask extends VisorMultiNodeTask, VisorCachePartitions> { - /** */ - private static final long serialVersionUID = 0L; - - /** {@inheritDoc} */ - @Override protected VisorCachePartitionsJob job(VisorCachePartitionsTaskArg arg) { - return new VisorCachePartitionsJob(arg, debug); - } - - /** {@inheritDoc} */ - @Nullable @Override protected Map reduce0(List results) { - Map parts = new HashMap<>(); - - for (ComputeJobResult res : results) { - if (res.getException() != null) - throw res.getException(); - - parts.put(res.getNode().id(), res.getData()); - } - - return parts; - } - - /** - * Job that collect cache metrics from node. - */ - private static class VisorCachePartitionsJob extends VisorJob { - /** */ - private static final long serialVersionUID = 0L; - - /** - * Create job with given argument. - * - * @param arg Tasks arguments. - * @param debug Debug flag. - */ - private VisorCachePartitionsJob(VisorCachePartitionsTaskArg arg, boolean debug) { - super(arg, debug); - } - - /** {@inheritDoc} */ - @Override protected VisorCachePartitions run(VisorCachePartitionsTaskArg arg) throws IgniteException { - String cacheName = arg.getCacheName(); - - if (debug) - log(ignite.log(), "Collecting partitions for cache: " + escapeName(cacheName)); - - VisorCachePartitions parts = new VisorCachePartitions(); - - GridCacheAdapter ca = ignite.context().cache().internalCache(cacheName); - - // Cache was not started. - if (ca == null || !ca.context().started() || VisorTaskUtils.isRestartingCache(ignite, cacheName)) - return parts; - - CacheConfiguration cfg = ca.configuration(); - - CacheMode mode = cfg.getCacheMode(); - - boolean partitioned = (mode == CacheMode.PARTITIONED || mode == CacheMode.REPLICATED) - && ca.context().affinityNode(); - - if (partitioned) { - GridDhtCacheAdapter dca = null; - - if (ca instanceof GridNearCacheAdapter) - dca = ((GridNearCacheAdapter)ca).dht(); - else if (ca instanceof GridDhtCacheAdapter) - dca = (GridDhtCacheAdapter)ca; - - if (dca != null) { - GridDhtPartitionTopology top = dca.topology(); - - List locParts = top.localPartitions(); - - for (GridDhtLocalPartition part : locParts) { - int p = part.id(); - - long sz = part.dataStore().cacheSize(ca.context().cacheId()); - - // Pass NONE as topology version in order not to wait for topology version. - if (part.primary(AffinityTopologyVersion.NONE)) - parts.addPrimary(p, sz); - else if (part.state() == GridDhtPartitionState.OWNING && part.backup(AffinityTopologyVersion.NONE)) - parts.addBackup(p, sz); - } - } - } - - return parts; - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorCachePartitionsJob.class, this); - } - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCachePartitionsTaskArg.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCachePartitionsTaskArg.java deleted file mode 100644 index 957f0718b8ca7..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCachePartitionsTaskArg.java +++ /dev/null @@ -1,72 +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.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; - -/** - * Arguments for {@link VisorCachePartitionsTask}. - */ -public class VisorCachePartitionsTaskArg extends VisorDataTransferObject { - /** */ - private static final long serialVersionUID = 0L; - - /** */ - private String cacheName; - - /** - * Default constructor. - */ - public VisorCachePartitionsTaskArg() { - // No-op. - } - - /** - * @param cacheName Cache name. - */ - public VisorCachePartitionsTaskArg(String cacheName) { - this.cacheName = cacheName; - } - - /** - * @return Cache name. - */ - public String getCacheName() { - return cacheName; - } - - /** {@inheritDoc} */ - @Override protected void writeExternalData(ObjectOutput out) throws IOException { - U.writeString(out, cacheName); - } - - /** {@inheritDoc} */ - @Override protected void readExternalData(byte protoVer, ObjectInput in) throws IOException, ClassNotFoundException { - cacheName = U.readString(in); - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorCachePartitionsTaskArg.class, this); - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheRebalanceTask.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheRebalanceTask.java deleted file mode 100644 index 58f8596bca410..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheRebalanceTask.java +++ /dev/null @@ -1,86 +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.util.ArrayList; -import java.util.Collection; -import org.apache.ignite.IgniteCheckedException; -import org.apache.ignite.internal.IgniteInternalFuture; -import org.apache.ignite.internal.processors.cache.IgniteInternalCache; -import org.apache.ignite.internal.processors.task.GridInternal; -import org.apache.ignite.internal.processors.task.GridVisorManagementTask; -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; - -/** - * Pre-loads caches. Made callable just to conform common pattern. - */ -@GridInternal -@GridVisorManagementTask -public class VisorCacheRebalanceTask extends VisorOneNodeTask { - /** */ - private static final long serialVersionUID = 0L; - - /** {@inheritDoc} */ - @Override protected VisorCachesRebalanceJob job(VisorCacheRebalanceTaskArg arg) { - return new VisorCachesRebalanceJob(arg, debug); - } - - /** - * Job that rebalance caches. - */ - private static class VisorCachesRebalanceJob extends VisorJob { - /** */ - private static final long serialVersionUID = 0L; - - /** - * @param arg Caches names. - * @param debug Debug flag. - */ - private VisorCachesRebalanceJob(VisorCacheRebalanceTaskArg arg, boolean debug) { - super(arg, debug); - } - - /** {@inheritDoc} */ - @Override protected Void run(VisorCacheRebalanceTaskArg arg) { - try { - Collection> futs = new ArrayList<>(); - - for (IgniteInternalCache c : ignite.cachesx()) { - if (arg.getCacheNames().contains(c.name())) - futs.add(c.rebalance()); - } - - for (IgniteInternalFuture f : futs) - f.get(); - - return null; - } - catch (IgniteCheckedException e) { - throw U.convertException(e); - } - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorCachesRebalanceJob.class, this); - } - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheRebalanceTaskArg.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheRebalanceTaskArg.java deleted file mode 100644 index 0bf420c52fbca..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheRebalanceTaskArg.java +++ /dev/null @@ -1,73 +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.IOException; -import java.io.ObjectInput; -import java.io.ObjectOutput; -import java.util.Set; -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; - -/** - * Argument for {@link VisorCacheRebalanceTask}. - */ -public class VisorCacheRebalanceTaskArg extends VisorDataTransferObject { - /** */ - private static final long serialVersionUID = 0L; - - /** Cache names. */ - private Set cacheNames; - - /** - * Default constructor. - */ - public VisorCacheRebalanceTaskArg() { - // No-op. - } - - /** - * @param cacheNames Cache names. - */ - public VisorCacheRebalanceTaskArg(Set cacheNames) { - this.cacheNames = cacheNames; - } - - /** - * @return Cache names. - */ - public Set getCacheNames() { - return cacheNames; - } - - /** {@inheritDoc} */ - @Override protected void writeExternalData(ObjectOutput out) throws IOException { - U.writeCollection(out, cacheNames); - } - - /** {@inheritDoc} */ - @Override protected void readExternalData(byte protoVer, ObjectInput in) throws IOException, ClassNotFoundException { - cacheNames = U.readSet(in); - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorCacheRebalanceTaskArg.class, this); - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheResetLostPartitionsTask.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheResetLostPartitionsTask.java deleted file mode 100644 index aa90d3e52a77d..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheResetLostPartitionsTask.java +++ /dev/null @@ -1,67 +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 org.apache.ignite.internal.processors.task.GridInternal; -import org.apache.ignite.internal.processors.task.GridVisorManagementTask; -import org.apache.ignite.internal.util.typedef.internal.S; -import org.apache.ignite.internal.visor.VisorJob; -import org.apache.ignite.internal.visor.VisorOneNodeTask; - -/** - * Reset lost partitions for caches. - */ -@GridInternal -@GridVisorManagementTask -public class VisorCacheResetLostPartitionsTask extends VisorOneNodeTask { - /** */ - private static final long serialVersionUID = 0L; - - /** {@inheritDoc} */ - @Override protected VisorCacheResetLostPartitionsJob job(VisorCacheResetLostPartitionsTaskArg arg) { - return new VisorCacheResetLostPartitionsJob(arg, debug); - } - - /** - * Job that reset lost partitions for caches. - */ - private static class VisorCacheResetLostPartitionsJob extends VisorJob { - /** */ - private static final long serialVersionUID = 0L; - - /** - * @param arg Object with list cache names to reset lost partitions. - * @param debug Debug flag. - */ - private VisorCacheResetLostPartitionsJob(VisorCacheResetLostPartitionsTaskArg arg, boolean debug) { - super(arg, debug); - } - - /** {@inheritDoc} */ - @Override protected Void run(VisorCacheResetLostPartitionsTaskArg arg) { - ignite.resetLostPartitions(arg.getCacheNames()); - - return null; - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorCacheResetLostPartitionsJob.class, this); - } - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheResetLostPartitionsTaskArg.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheResetLostPartitionsTaskArg.java deleted file mode 100644 index c69e79db6d51c..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheResetLostPartitionsTaskArg.java +++ /dev/null @@ -1,81 +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.IOException; -import java.io.ObjectInput; -import java.io.ObjectOutput; -import java.util.List; -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; - -/** - * Argument for {@link VisorCacheResetLostPartitionsTask}. - */ -public class VisorCacheResetLostPartitionsTaskArg extends VisorDataTransferObject { - /** */ - private static final long serialVersionUID = 0L; - - /** List of cache names. */ - private List cacheNames; - - /** Created for toString method because Collection can't be printed. */ - private String modifiedCaches; - - /** - * Default constructor. - */ - public VisorCacheResetLostPartitionsTaskArg() { - // No-op. - } - - /** - * @param cacheNames List of cache names. - */ - public VisorCacheResetLostPartitionsTaskArg(List cacheNames) { - this.cacheNames = cacheNames; - - if (cacheNames != null) - modifiedCaches = cacheNames.toString(); - } - - /** - * @return List of cache names. - */ - public List getCacheNames() { - return cacheNames; - } - - /** {@inheritDoc} */ - @Override protected void writeExternalData(ObjectOutput out) throws IOException { - U.writeCollection(out, cacheNames); - U.writeString(out, modifiedCaches); - } - - /** {@inheritDoc} */ - @Override protected void readExternalData(byte protoVer, ObjectInput in) throws IOException, ClassNotFoundException { - cacheNames = U.readList(in); - modifiedCaches = U.readString(in); - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorCacheResetLostPartitionsTaskArg.class, this); - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheResetMetricsTask.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheResetMetricsTask.java deleted file mode 100644 index e17ecb0087469..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheResetMetricsTask.java +++ /dev/null @@ -1,69 +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 org.apache.ignite.internal.processors.cache.GridCacheAdapter; -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.VisorOneNodeTask; - -/** - * Reset compute grid metrics. - */ -@GridInternal -public class VisorCacheResetMetricsTask extends VisorOneNodeTask { - /** */ - private static final long serialVersionUID = 0L; - - /** {@inheritDoc} */ - @Override protected VisorCacheResetMetricsJob job(VisorCacheResetMetricsTaskArg arg) { - return new VisorCacheResetMetricsJob(arg, debug); - } - - /** - * Job that reset cache metrics. - */ - private static class VisorCacheResetMetricsJob extends VisorJob { - /** */ - private static final long serialVersionUID = 0L; - - /** - * @param arg Cache name to reset metrics for. - * @param debug Debug flag. - */ - private VisorCacheResetMetricsJob(VisorCacheResetMetricsTaskArg arg, boolean debug) { - super(arg, debug); - } - - /** {@inheritDoc} */ - @Override protected Void run(VisorCacheResetMetricsTaskArg arg) { - GridCacheAdapter cache = ignite.context().cache().internalCache(arg.getCacheName()); - - if (cache != null) - cache.metrics0().clear(); - - return null; - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorCacheResetMetricsJob.class, this); - } - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheResetMetricsTaskArg.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheResetMetricsTaskArg.java deleted file mode 100644 index 3a9d8aef0b532..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheResetMetricsTaskArg.java +++ /dev/null @@ -1,72 +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.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; - -/** - * Argument for {@link VisorCacheResetMetricsTask}. - */ -public class VisorCacheResetMetricsTaskArg extends VisorDataTransferObject { - /** */ - private static final long serialVersionUID = 0L; - - /** Cache name. */ - private String cacheName; - - /** - * Default constructor. - */ - public VisorCacheResetMetricsTaskArg() { - // No-op. - } - - /** - * @param cacheName Cache name. - */ - public VisorCacheResetMetricsTaskArg(String cacheName) { - this.cacheName = cacheName; - } - - /** - * @return Cache name. - */ - public String getCacheName() { - return cacheName; - } - - /** {@inheritDoc} */ - @Override protected void writeExternalData(ObjectOutput out) throws IOException { - U.writeString(out, cacheName); - } - - /** {@inheritDoc} */ - @Override protected void readExternalData(byte protoVer, ObjectInput in) throws IOException, ClassNotFoundException { - cacheName = U.readString(in); - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorCacheResetMetricsTaskArg.class, this); - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheSqlIndexMetadata.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheSqlIndexMetadata.java deleted file mode 100644 index cd4c95cc3affc..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheSqlIndexMetadata.java +++ /dev/null @@ -1,115 +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.IOException; -import java.io.ObjectInput; -import java.io.ObjectOutput; -import java.util.List; -import org.apache.ignite.internal.processors.cache.query.GridCacheSqlIndexMetadata; -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 cache SQL index metadata. - */ -public class VisorCacheSqlIndexMetadata extends VisorDataTransferObject { - /** */ - private static final long serialVersionUID = 0L; - - /** */ - private String name; - - /** */ - private List fields; - - /** */ - private List descendings; - - /** */ - private boolean unique; - - /** - * Default constructor. - */ - public VisorCacheSqlIndexMetadata() { - // No-op. - } - - /** - * Create data transfer object. - * - * @param meta SQL index metadata. - */ - public VisorCacheSqlIndexMetadata(GridCacheSqlIndexMetadata meta) { - name = meta.name(); - fields = toList(meta.fields()); - descendings = toList(meta.descendings()); - unique = meta.unique(); - } - - /** - * @return Index name. - */ - public String getName() { - return name; - } - - /** - * @return Indexed fields names. - */ - public List getFields() { - return fields; - } - - /** - * @return Descendings. - */ - public List getDescendings() { - return descendings; - } - - /** - * @return {@code True} if index is unique, {@code false} otherwise. - */ - public boolean isUnique() { - return unique; - } - - /** {@inheritDoc} */ - @Override protected void writeExternalData(ObjectOutput out) throws IOException { - U.writeString(out, name); - U.writeCollection(out, fields); - U.writeCollection(out, descendings); - out.writeBoolean(unique); - } - - /** {@inheritDoc} */ - @Override protected void readExternalData(byte protoVer, ObjectInput in) throws IOException, ClassNotFoundException { - name = U.readString(in); - fields = U.readList(in); - descendings = U.readList(in); - unique = in.readBoolean(); - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorCacheSqlIndexMetadata.class, this); - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheSqlMetadata.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheSqlMetadata.java deleted file mode 100644 index 7da9c975836a9..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheSqlMetadata.java +++ /dev/null @@ -1,162 +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.IOException; -import java.io.ObjectInput; -import java.io.ObjectOutput; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import org.apache.ignite.internal.processors.cache.query.GridCacheSqlIndexMetadata; -import org.apache.ignite.internal.processors.cache.query.GridCacheSqlMetadata; -import org.apache.ignite.internal.util.IgniteUtils; -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 cache SQL metadata. - */ -public class VisorCacheSqlMetadata extends VisorDataTransferObject { - /** */ - private static final long serialVersionUID = 0L; - - /** */ - private String cacheName; - - /** */ - private List types; - - /** */ - private Map keyClasses; - - /** */ - private Map valClasses; - - /** */ - private Map> fields; - - /** */ - private Map> indexes; - - /** - * Default constructor. - */ - public VisorCacheSqlMetadata() { - // No-op. - } - - /** - * Create data transfer object. - * - * @param meta Cache SQL metadata. - */ - public VisorCacheSqlMetadata(GridCacheSqlMetadata meta) { - cacheName = meta.cacheName(); - types = toList(meta.types()); - keyClasses = meta.keyClasses(); - valClasses = meta.valClasses(); - fields = meta.fields(); - indexes = new HashMap<>(); - - Map> src = meta.indexes(); - - if (src != null) { - for (Map.Entry> entry: src.entrySet()) { - Collection idxs = entry.getValue(); - - List res = new ArrayList<>(idxs.size()); - - for (GridCacheSqlIndexMetadata idx : idxs) - res.add(new VisorCacheSqlIndexMetadata(idx)); - - indexes.put(entry.getKey(), res); - } - } - } - - /** - * @return Cache name. - */ - public String getCacheName() { - return cacheName; - } - - /** - * @return Collection of available types. - */ - public List getTypes() { - return types; - } - - /** - * @return Key classes. - */ - public Map getKeyClasses() { - return keyClasses; - } - - /** - * @return Value classes. - */ - public Map getValueClasses() { - return valClasses; - } - - /** - * @return Fields. - */ - public Map> getFields() { - return fields; - } - - /** - * @return Indexes. - */ - public Map> getIndexes() { - return indexes; - } - - /** {@inheritDoc} */ - @Override protected void writeExternalData(ObjectOutput out) throws IOException { - U.writeString(out, cacheName); - U.writeCollection(out, types); - IgniteUtils.writeStringMap(out, keyClasses); - IgniteUtils.writeStringMap(out, valClasses); - U.writeMap(out, fields); - U.writeMap(out, indexes); - } - - /** {@inheritDoc} */ - @Override protected void readExternalData(byte protoVer, ObjectInput in) throws IOException, ClassNotFoundException { - cacheName = U.readString(in); - types = U.readList(in); - keyClasses = IgniteUtils.readStringMap(in); - valClasses = IgniteUtils.readStringMap(in); - fields = U.readMap(in); - indexes = U.readMap(in); - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorCacheSqlMetadata.class, this); - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheStartTask.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheStartTask.java deleted file mode 100644 index 2e96a4b2139d5..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheStartTask.java +++ /dev/null @@ -1,112 +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.ByteArrayInputStream; -import java.io.IOException; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.UUID; -import org.apache.ignite.IgniteException; -import org.apache.ignite.Ignition; -import org.apache.ignite.compute.ComputeJobResult; -import org.apache.ignite.configuration.CacheConfiguration; -import org.apache.ignite.configuration.NearCacheConfiguration; -import org.apache.ignite.internal.processors.task.GridInternal; -import org.apache.ignite.internal.processors.task.GridVisorManagementTask; -import org.apache.ignite.internal.util.typedef.F; -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.internal.visor.util.VisorTaskUtils; -import org.jetbrains.annotations.Nullable; - -/** - * Task that start cache or near cache with specified configuration. - */ -@GridInternal -@GridVisorManagementTask -public class VisorCacheStartTask extends VisorMultiNodeTask, Void> { - /** */ - private static final long serialVersionUID = 0L; - - /** {@inheritDoc} */ - @Override protected VisorCacheStartJob job(VisorCacheStartTaskArg arg) { - return new VisorCacheStartJob(arg, debug); - } - - /** {@inheritDoc} */ - @Nullable @Override protected Map reduce0(List results) throws IgniteException { - Map map = new HashMap<>(); - - for (ComputeJobResult res : results) - if (res.getException() != null) - map.put(res.getNode().id(), res.getException()); - - return map; - } - - /** - * Job that start cache or near cache with specified configuration. - */ - private static class VisorCacheStartJob extends VisorJob { - /** */ - private static final long serialVersionUID = 0L; - - /** - * Create job. - * - * @param arg Contains cache name and XML configurations of cache. - * @param debug Debug flag. - */ - private VisorCacheStartJob(VisorCacheStartTaskArg arg, boolean debug) { - super(arg, debug); - } - - /** {@inheritDoc} */ - @Override protected Void run(VisorCacheStartTaskArg arg) throws IgniteException { - String cfg = arg.getConfiguration(); - - assert !F.isEmpty(cfg); - - try (ByteArrayInputStream bais = new ByteArrayInputStream(cfg.getBytes())) { - if (arg.isNear()) { - NearCacheConfiguration nearCfg = Ignition.loadSpringBean(bais, "nearCacheConfiguration"); - - ignite.getOrCreateNearCache(VisorTaskUtils.unescapeName(arg.getName()), nearCfg); - } - else { - CacheConfiguration cacheCfg = Ignition.loadSpringBean(bais, "cacheConfiguration"); - - ignite.getOrCreateCache(cacheCfg); - } - } - catch (IOException e) { - throw new IgniteException(e); - } - - return null; - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorCacheStartJob.class, this); - } - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheStartTaskArg.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheStartTaskArg.java deleted file mode 100644 index 0b058aea525c8..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheStartTaskArg.java +++ /dev/null @@ -1,100 +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.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; - -/** - * Cache start arguments. - */ -public class VisorCacheStartTaskArg extends VisorDataTransferObject { - /** */ - private static final long serialVersionUID = 0L; - - /** */ - private boolean near; - - /** */ - private String name; - - /** */ - private String cfg; - - /** - * Default constructor. - */ - public VisorCacheStartTaskArg() { - // No-op. - } - - /** - * @param near {@code true} if near cache should be started. - * @param name Name for near cache. - * @param cfg Cache XML configuration. - */ - public VisorCacheStartTaskArg(boolean near, String name, String cfg) { - this.near = near; - this.name = name; - this.cfg = cfg; - } - - /** - * @return {@code true} if near cache should be started. - */ - public boolean isNear() { - return near; - } - - /** - * @return Name for near cache. - */ - public String getName() { - return name; - } - - /** - * @return Cache XML configuration. - */ - public String getConfiguration() { - return cfg; - } - - /** {@inheritDoc} */ - @Override protected void writeExternalData(ObjectOutput out) throws IOException { - out.writeBoolean(near); - U.writeString(out, name); - U.writeString(out, cfg); - } - - /** {@inheritDoc} */ - @Override protected void readExternalData(byte protoVer, ObjectInput in) throws IOException, ClassNotFoundException { - near = in.readBoolean(); - name = U.readString(in); - cfg = U.readString(in); - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorCacheStartTaskArg.class, this); - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheToggleStatisticsTask.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheToggleStatisticsTask.java deleted file mode 100644 index aebed810d2cc0..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheToggleStatisticsTask.java +++ /dev/null @@ -1,72 +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 org.apache.ignite.IgniteCheckedException; -import org.apache.ignite.internal.processors.task.GridInternal; -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; - -/** - * Switch statisticsEnabled flag for specified caches to specified state. - */ -@GridInternal -public class VisorCacheToggleStatisticsTask extends VisorOneNodeTask { - /** */ - private static final long serialVersionUID = 0L; - - /** {@inheritDoc} */ - @Override protected VisorCachesToggleStatisticsJob job(VisorCacheToggleStatisticsTaskArg arg) { - return new VisorCachesToggleStatisticsJob(arg, debug); - } - - /** - * Job that switch statisticsEnabled flag for specified caches to specified state. - */ - private static class VisorCachesToggleStatisticsJob extends VisorJob { - /** */ - private static final long serialVersionUID = 0L; - - /** - * @param arg Job argument object. - * @param debug Debug flag. - */ - private VisorCachesToggleStatisticsJob(VisorCacheToggleStatisticsTaskArg arg, boolean debug) { - super(arg, debug); - } - - /** {@inheritDoc} */ - @Override protected Void run(VisorCacheToggleStatisticsTaskArg arg) { - try { - ignite.context().cache().enableStatistics(arg.getCacheNames(), arg.getState()); - } - catch (IgniteCheckedException e) { - throw U.convertException(e); - } - - return null; - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorCachesToggleStatisticsJob.class, this); - } - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheToggleStatisticsTaskArg.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheToggleStatisticsTaskArg.java deleted file mode 100644 index 34359daeacf6c..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheToggleStatisticsTaskArg.java +++ /dev/null @@ -1,87 +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.IOException; -import java.io.ObjectInput; -import java.io.ObjectOutput; -import java.util.Set; -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; - -/** - * Argument for {@link VisorCacheToggleStatisticsTask}. - */ -public class VisorCacheToggleStatisticsTaskArg extends VisorDataTransferObject { - /** */ - private static final long serialVersionUID = 0L; - - /** State to set to statisticsEnabled flag. */ - private boolean state; - - /** Cache names to toggle statisticsEnabled flag. */ - private Set cacheNames; - - /** - * Default constructor. - */ - public VisorCacheToggleStatisticsTaskArg() { - // No-op. - } - - /** - * @param state State to set to statisticsEnabled flag. - * @param cacheNames Collection of cache names to toggle statisticsEnabled flag. - */ - public VisorCacheToggleStatisticsTaskArg(boolean state, Set cacheNames) { - this.state = state; - this.cacheNames = cacheNames; - } - - /** - * @return State to set to statisticsEnabled flag. - */ - public boolean getState() { - return state; - } - - /** - * @return Cache names to toggle statisticsEnabled flag. - */ - public Set getCacheNames() { - return cacheNames; - } - - /** {@inheritDoc} */ - @Override protected void writeExternalData(ObjectOutput out) throws IOException { - out.writeBoolean(state); - U.writeCollection(out, cacheNames); - } - - /** {@inheritDoc} */ - @Override protected void readExternalData(byte protoVer, ObjectInput in) throws IOException, ClassNotFoundException { - state = in.readBoolean(); - cacheNames = U.readSet(in); - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorCacheToggleStatisticsTaskArg.class, this); - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorMemoryMetrics.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorMemoryMetrics.java deleted file mode 100644 index d9ac08a8e3529..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorMemoryMetrics.java +++ /dev/null @@ -1,352 +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.IOException; -import java.io.ObjectInput; -import java.io.ObjectOutput; -import org.apache.ignite.DataRegionMetrics; -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 {@link DataRegionMetrics} - */ -public class VisorMemoryMetrics extends VisorDataTransferObject { - /** */ - private static final long serialVersionUID = 0L; - - /** */ - private String name; - - /** */ - private long totalAllocatedPages; - - /** */ - private float allocationRate; - - /** */ - private float evictionRate; - - /** */ - private float largeEntriesPagesPercentage; - - /** */ - private float pagesFillFactor; - - /** */ - private long dirtyPages; - - /** */ - private float pagesReplaceRate; - - /** */ - private long physicalMemoryPages; - - /** */ - private long totalAllocatedSz; - - /** */ - private long physicalMemSz; - - /** */ - private int pageSize; - - /** */ - private long cpBufSz; - - /** */ - private long cpUsedBufPages; - - /** */ - private long cpUsedBufSz; - - /** */ - private long pagesRead; - - /** */ - private long pagesWritten; - - /** */ - private long pagesReplaced; - - /** */ - private long offHeapSz; - - /** */ - private long offHeapUsedSz; - - /** - * Default constructor. - */ - public VisorMemoryMetrics() { - // No-op. - } - - /** - * @param m Metrics instance to create DTO. - */ - public VisorMemoryMetrics(DataRegionMetrics m) { - name = m.getName(); - totalAllocatedPages = m.getTotalAllocatedPages(); - allocationRate = m.getAllocationRate(); - evictionRate = m.getEvictionRate(); - largeEntriesPagesPercentage = m.getLargeEntriesPagesPercentage(); - pagesFillFactor = m.getPagesFillFactor(); - dirtyPages = m.getDirtyPages(); - pagesReplaceRate = m.getPagesReplaceRate(); - physicalMemoryPages = m.getPhysicalMemoryPages(); - totalAllocatedSz = m.getTotalAllocatedSize(); - physicalMemSz = m.getPhysicalMemorySize(); - - pageSize = m.getPageSize(); - - cpBufSz = m.getCheckpointBufferSize(); - cpUsedBufPages = m.getUsedCheckpointBufferPages(); - cpUsedBufSz = m.getUsedCheckpointBufferSize(); - - pagesRead = m.getPagesRead(); - pagesWritten = m.getPagesWritten(); - pagesReplaced = m.getPagesReplaced(); - - offHeapSz = m.getOffHeapSize(); - offHeapUsedSz = m.getOffheapUsedSize(); - } - - /** - * @return Name of the memory region. - */ - public String getName() { - return name; - } - - /** - * @return Total number of allocated pages. - */ - public long getTotalAllocatedPages() { - return totalAllocatedPages; - } - - /** - * @return Number of allocated pages per second. - */ - public float getAllocationRate() { - return allocationRate; - } - - /** - * @return Eviction rate. - */ - public float getEvictionRate() { - return evictionRate; - } - - /** - * @return Number of evicted pages per second. - */ - public float getLargeEntriesPagesPercentage() { - return largeEntriesPagesPercentage; - } - - /** - * @return Percentage of pages fully occupied by large entities. - */ - public float getPagesFillFactor() { - return pagesFillFactor; - } - - /** - * @return Current number of dirty pages. - */ - public long getDirtyPages() { - return dirtyPages; - } - - /** - * @return Pages per second replace rate. - */ - public float getPagesReplaceRate() { - return pagesReplaceRate; - } - - /** - * @return Total number of pages loaded to RAM. - */ - public long getPhysicalMemoryPages() { - return physicalMemoryPages; - } - - /** - * @return Total size of memory allocated, in bytes. - */ - public long getTotalAllocatedSize() { - return totalAllocatedSz; - } - - /** - * @return Total size of pages loaded to RAM in bytes. - */ - public long getPhysicalMemorySize() { - return physicalMemSz; - } - - /** - * This method needed for compatibility with V2. - * - * @return Used checkpoint buffer size in pages. - */ - public long getCheckpointBufferPages() { - return cpUsedBufPages; - } - - /** - * @return @return Checkpoint buffer size in bytes. - */ - public long getCheckpointBufferSize() { - return cpBufSz; - } - - /** - * @return Used checkpoint buffer size in pages. - */ - public long getUsedCheckpointBufferPages() { - return cpUsedBufPages; - } - - /** - * @return Used checkpoint buffer size in bytes. - */ - public long getUsedCheckpointBufferSize() { - return cpUsedBufSz; - } - - /** - * @return Page size in bytes. - */ - public int getPageSize() { - return pageSize; - } - - /** - * @return The number of read pages from last restart. - */ - public long getPagesRead() { - return pagesRead; - } - - /** - * @return The number of written pages from last restart. - */ - public long getPagesWritten() { - return pagesWritten; - } - - /** - * @return The number of replaced pages from last restart . - */ - public long getPagesReplaced() { - return pagesReplaced; - } - - /** - * @return Total offheap size in bytes. - */ - public long getOffHeapSize() { - return offHeapSz; - } - - /** - * @return Total used offheap size in bytes. - */ - public long getOffheapUsedSize() { - return offHeapUsedSz; - } - - /** {@inheritDoc} */ - @Override public byte getProtocolVersion() { - return V3; - } - - /** {@inheritDoc} */ - @Override protected void writeExternalData(ObjectOutput out) throws IOException { - U.writeString(out, name); - out.writeLong(totalAllocatedPages); - out.writeFloat(allocationRate); - out.writeFloat(evictionRate); - out.writeFloat(largeEntriesPagesPercentage); - out.writeFloat(pagesFillFactor); - out.writeLong(dirtyPages); - out.writeFloat(pagesReplaceRate); - out.writeLong(physicalMemoryPages); - - // V2 - out.writeLong(totalAllocatedSz); - out.writeLong(physicalMemSz); - out.writeLong(cpUsedBufPages); - out.writeLong(cpBufSz); - out.writeInt(pageSize); - - // V3 - out.writeLong(cpUsedBufSz); - - out.writeLong(pagesRead); - out.writeLong(pagesWritten); - out.writeLong(pagesReplaced); - - out.writeLong(offHeapSz); - out.writeLong(offHeapUsedSz); - } - - /** {@inheritDoc} */ - @Override protected void readExternalData(byte protoVer, ObjectInput in) throws IOException, ClassNotFoundException { - name = U.readString(in); - totalAllocatedPages = in.readLong(); - allocationRate = in.readFloat(); - evictionRate = in.readFloat(); - largeEntriesPagesPercentage = in.readFloat(); - pagesFillFactor = in.readFloat(); - dirtyPages = in.readLong(); - pagesReplaceRate = in.readFloat(); - physicalMemoryPages = in.readLong(); - - if (protoVer > V1) { - totalAllocatedSz = in.readLong(); - physicalMemSz = in.readLong(); - cpUsedBufPages = in.readLong(); - cpBufSz = in.readLong(); - pageSize = in.readInt(); - } - - if (protoVer > V2) { - cpUsedBufSz = in.readLong(); - - pagesRead = in.readLong(); - pagesWritten = in.readLong(); - pagesReplaced = in.readLong(); - - offHeapSz = in.readLong(); - offHeapUsedSz = in.readLong(); - } - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorMemoryMetrics.class, this); - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorModifyCacheMode.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorModifyCacheMode.java deleted file mode 100644 index bd47f66c0af11..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorModifyCacheMode.java +++ /dev/null @@ -1,47 +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 org.jetbrains.annotations.Nullable; - -/** - * Enumeration of all supported cache modify modes. - */ -public enum VisorModifyCacheMode { - /** Put new value into cache. */ - PUT, - - /** Get value from cache. */ - GET, - - /** Remove value from cache. */ - REMOVE; - - /** Enumerated values. */ - private static final VisorModifyCacheMode[] VALS = values(); - - /** - * Efficiently gets enumerated value from its ordinal. - * - * @param ord Ordinal value. - * @return Enumerated value or {@code null} if ordinal out of range. - */ - @Nullable public static VisorModifyCacheMode fromOrdinal(int ord) { - return ord >= 0 && ord < VALS.length ? VALS[ord] : null; - } -} 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 deleted file mode 100644 index 17c91a70f338f..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorPartitionMap.java +++ /dev/null @@ -1,110 +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.IOException; -import java.io.ObjectInput; -import java.io.ObjectOutput; -import java.util.HashMap; -import java.util.Map; -import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionMap; -import org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtPartitionState; -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 parts; - - /** - * Default constructor. - */ - public VisorPartitionMap() { - // No-op. - } - - /** - * @param map Partitions map. - */ - public VisorPartitionMap(GridDhtPartitionMap map) { - parts = map.map(); - } - - /** - * @return Partitions map. - */ - public Map 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 { - if (parts != null) { - out.writeInt(parts.size()); - - for (Map.Entry e : parts.entrySet()) { - out.writeInt(e.getKey()); - U.writeEnum(out, e.getValue()); - } - } - else - out.writeInt(-1); - } - - /** {@inheritDoc} */ - @Override protected void readExternalData(byte protoVer, ObjectInput in) throws IOException, ClassNotFoundException { - int size = in.readInt(); - - // Check null flag. - if (size == -1) - parts = null; - else { - parts = new HashMap<>(size, 1.0f); - - for (int i = 0; i < size; i++) - parts.put(in.readInt(), GridDhtPartitionState.fromOrdinal(in.readByte())); - } - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorPartitionMap.class, this); - } -} 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 deleted file mode 100644 index 42eb4f5ba80bf..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/compute/VisorComputeMonitoringHolder.java +++ /dev/null @@ -1,121 +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.compute; - -import java.util.HashMap; -import java.util.Map; -import org.apache.ignite.internal.IgniteEx; -import org.apache.ignite.internal.processors.timeout.GridTimeoutObjectAdapter; -import org.apache.ignite.internal.util.typedef.internal.S; - -import static org.apache.ignite.internal.visor.util.VisorTaskUtils.VISOR_TASK_EVTS; - -/** - * Holder class to store information in node local map between data collector task executions. - */ -public class VisorComputeMonitoringHolder { - /** Task monitoring events holder key. */ - public static final String COMPUTE_MONITORING_HOLDER_KEY = "VISOR_COMPUTE_MONITORING_KEY"; - - /** Visors that collect events (Visor instance key -> collect events since last cleanup check) */ - private final Map listenVisor = new HashMap<>(); - - /** If cleanup process not scheduled. */ - private boolean cleanupStopped = true; - - /** Timeout between disable events check. */ - protected static final int CLEANUP_TIMEOUT = 2 * 60 * 1000; - - /** - * Start collect events for Visor instance. - * - * @param ignite Grid. - * @param visorKey unique Visor instance key. - */ - public void startCollect(IgniteEx ignite, String visorKey) { - synchronized (listenVisor) { - if (cleanupStopped) { - scheduleCleanupJob(ignite); - - cleanupStopped = false; - } - - listenVisor.put(visorKey, Boolean.TRUE); - - ignite.events().enableLocal(VISOR_TASK_EVTS); - } - } - - /** - * Check if collect events may be disable. - * - * @param ignite Grid. - * @return {@code true} if task events should remain enabled. - */ - private boolean tryDisableEvents(IgniteEx ignite) { - if (!listenVisor.values().contains(Boolean.TRUE)) { - listenVisor.clear(); - - ignite.events().disableLocal(VISOR_TASK_EVTS); - } - - // Return actual state. It could stay the same if events explicitly enabled in configuration. - return ignite.allEventsUserRecordable(VISOR_TASK_EVTS); - } - - /** - * Disable collect events for Visor instance. - * - * @param g Grid. - * @param visorKey Unique Visor instance key. - */ - public void stopCollect(IgniteEx g, String visorKey) { - synchronized (listenVisor) { - listenVisor.remove(visorKey); - - tryDisableEvents(g); - } - } - - /** - * Schedule cleanup process for events monitoring. - * - * @param ignite grid. - */ - private void scheduleCleanupJob(final IgniteEx ignite) { - ignite.context().timeout().addTimeoutObject(new GridTimeoutObjectAdapter(CLEANUP_TIMEOUT) { - @Override public void onTimeout() { - synchronized (listenVisor) { - if (tryDisableEvents(ignite)) { - for (String visorKey : listenVisor.keySet()) - listenVisor.put(visorKey, Boolean.FALSE); - - scheduleCleanupJob(ignite); - } - else - cleanupStopped = true; - } - } - }); - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorComputeMonitoringHolder.class, this); - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/compute/VisorComputeResetMetricsTask.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/compute/VisorComputeResetMetricsTask.java deleted file mode 100644 index f9bc6248f9028..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/compute/VisorComputeResetMetricsTask.java +++ /dev/null @@ -1,67 +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.compute; - -import org.apache.ignite.internal.processors.task.GridInternal; -import org.apache.ignite.internal.processors.task.GridVisorManagementTask; -import org.apache.ignite.internal.util.typedef.internal.S; -import org.apache.ignite.internal.visor.VisorJob; -import org.apache.ignite.internal.visor.VisorOneNodeTask; - -/** - * Reset compute grid metrics task. - */ -@GridInternal -@GridVisorManagementTask -public class VisorComputeResetMetricsTask extends VisorOneNodeTask { - /** */ - private static final long serialVersionUID = 0L; - - /** {@inheritDoc} */ - @Override protected VisorComputeResetMetricsJob job(Void arg) { - return new VisorComputeResetMetricsJob(arg, debug); - } - - /** - * Reset compute grid metrics job. - */ - private static class VisorComputeResetMetricsJob extends VisorJob { - /** */ - private static final long serialVersionUID = 0L; - - /** - * @param arg Formal job argument. - * @param debug Debug flag. - */ - private VisorComputeResetMetricsJob(Void arg, boolean debug) { - super(arg, debug); - } - - /** {@inheritDoc} */ - @Override protected Void run(Void arg) { - ignite.cluster().resetMetrics(); - - return null; - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorComputeResetMetricsJob.class, this); - } - } -} 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 deleted file mode 100644 index e9bd940d3ccc8..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/compute/VisorComputeToggleMonitoringTask.java +++ /dev/null @@ -1,112 +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.compute; - -import java.util.Collection; -import java.util.HashSet; -import java.util.List; -import java.util.concurrent.ConcurrentMap; -import org.apache.ignite.compute.ComputeJobResult; -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.jetbrains.annotations.Nullable; - -import static org.apache.ignite.internal.visor.compute.VisorComputeMonitoringHolder.COMPUTE_MONITORING_HOLDER_KEY; -import static org.apache.ignite.internal.visor.util.VisorTaskUtils.VISOR_TASK_EVTS; -import static org.apache.ignite.internal.visor.util.VisorTaskUtils.checkExplicitTaskMonitoring; - -/** - * Task to run gc on nodes. - */ -@GridInternal -public class VisorComputeToggleMonitoringTask extends - VisorMultiNodeTask { - /** */ - private static final long serialVersionUID = 0L; - - /** {@inheritDoc} */ - @Nullable @Override protected Boolean reduce0(List results) { - Collection toggles = new HashSet<>(); - - for (ComputeJobResult res : results) - toggles.add(res.getData()); - - // If all nodes return same result. - return toggles.size() == 1; - } - - /** {@inheritDoc} */ - @Override protected VisorComputeToggleMonitoringJob job(VisorComputeToggleMonitoringTaskArg arg) { - return new VisorComputeToggleMonitoringJob(arg, debug); - } - - /** - * Job to toggle task monitoring on node. - */ - private static class VisorComputeToggleMonitoringJob extends VisorJob { - /** */ - private static final long serialVersionUID = 0L; - - /** - * @param arg Visor ID key and monitoring state flag. - * @param debug Debug flag. - */ - private VisorComputeToggleMonitoringJob(VisorComputeToggleMonitoringTaskArg arg, boolean debug) { - super(arg, debug); - } - - /** {@inheritDoc} */ - @Override protected Boolean run(VisorComputeToggleMonitoringTaskArg arg) { - if (checkExplicitTaskMonitoring(ignite)) - return Boolean.TRUE; - - ConcurrentMap storage = ignite.cluster().nodeLocalMap(); - - VisorComputeMonitoringHolder holder = storage.get(COMPUTE_MONITORING_HOLDER_KEY); - - if (holder == null) { - VisorComputeMonitoringHolder holderNew = new VisorComputeMonitoringHolder(); - - VisorComputeMonitoringHolder holderOld = - storage.putIfAbsent(COMPUTE_MONITORING_HOLDER_KEY, holderNew); - - holder = holderOld == null ? holderNew : holderOld; - } - - String visorKey = arg.getVisorKey(); - - boolean state = arg.isEnabled(); - - // 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} */ - @Override public String toString() { - return S.toString(VisorComputeToggleMonitoringJob.class, this); - } - } -} 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 deleted file mode 100644 index e17379a08f8fc..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/compute/VisorComputeToggleMonitoringTaskArg.java +++ /dev/null @@ -1,86 +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.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); - } -} 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 deleted file mode 100644 index 46d670cda01f1..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/compute/VisorGatewayTask.java +++ /dev/null @@ -1,485 +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.compute; - -import java.lang.reflect.Constructor; -import java.math.BigDecimal; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.UUID; -import org.apache.ignite.IgniteCompute; -import org.apache.ignite.IgniteException; -import org.apache.ignite.cluster.ClusterNode; -import org.apache.ignite.compute.ComputeJob; -import org.apache.ignite.compute.ComputeJobAdapter; -import org.apache.ignite.compute.ComputeJobContext; -import org.apache.ignite.compute.ComputeJobResult; -import org.apache.ignite.compute.ComputeJobResultPolicy; -import org.apache.ignite.compute.ComputeTask; -import org.apache.ignite.internal.IgniteEx; -import org.apache.ignite.internal.processors.security.PublicAccessJob; -import org.apache.ignite.internal.processors.task.GridInternal; -import org.apache.ignite.internal.util.lang.GridTuple3; -import org.apache.ignite.internal.util.typedef.CI1; -import org.apache.ignite.internal.util.typedef.F; -import org.apache.ignite.internal.visor.VisorCoordinatorNodeTask; -import org.apache.ignite.internal.visor.VisorOneNodeTask; -import org.apache.ignite.internal.visor.VisorTaskArgument; -import org.apache.ignite.lang.IgniteBiTuple; -import org.apache.ignite.lang.IgniteFuture; -import org.apache.ignite.lang.IgniteUuid; -import org.apache.ignite.plugin.security.SecurityPermissionSet; -import org.apache.ignite.resources.IgniteInstanceResource; -import org.apache.ignite.resources.JobContextResource; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import static org.apache.ignite.plugin.security.SecurityPermission.ADMIN_OPS; -import static org.apache.ignite.plugin.security.SecurityPermissionSetBuilder.systemPermissions; - -/** - * Task to run Visor tasks through http REST. - */ -@GridInternal -public class VisorGatewayTask implements ComputeTask { - /** */ - private static final long serialVersionUID = 0L; - - /** */ - private static final int JOB_ARG_IDX = 3; - - /** Array with additional length in arguments for specific nested types */ - private static final Map TYPE_ARG_LENGTH = new HashMap<>(4); - - static { - TYPE_ARG_LENGTH.put(Collection.class, 2); - TYPE_ARG_LENGTH.put(Set.class, 2); - TYPE_ARG_LENGTH.put(List.class, 2); - TYPE_ARG_LENGTH.put(Map.class, 3); - TYPE_ARG_LENGTH.put(IgniteBiTuple.class, 4); - TYPE_ARG_LENGTH.put(GridTuple3.class, 6); - } - - /** Auto-injected grid instance. */ - @IgniteInstanceResource - protected transient IgniteEx ignite; - - /** {@inheritDoc} */ - @NotNull @Override public Map map(List subgrid, - @Nullable Object[] args) throws IgniteException { - assert args != null; - assert args.length >= 2; - - return Collections.singletonMap(new VisorGatewayJob(args), ignite.localNode()); - } - - /** {@inheritDoc} */ - @Override public ComputeJobResultPolicy result(ComputeJobResult res, - List rcvd) throws IgniteException { - // Task should handle exceptions in reduce method. - return ComputeJobResultPolicy.WAIT; - } - - /** {@inheritDoc} */ - @Nullable @Override public Object reduce(List results) throws IgniteException { - assert results.size() == 1; - - ComputeJobResult res = F.first(results); - - assert res != null; - - IgniteException ex = res.getException(); - - if (ex != null) - throw ex; - - return res.getData(); - } - - /** - * Job to run Visor tasks through http REST. - */ - private static class VisorGatewayJob extends ComputeJobAdapter implements PublicAccessJob { - /** */ - private static final long serialVersionUID = 0L; - - /** */ - private static final byte[] ZERO_BYTES = new byte[0]; - - /** Auto-injected grid instance. */ - @IgniteInstanceResource - protected transient IgniteEx ignite; - - /** Auto-inject job context. */ - @JobContextResource - protected transient ComputeJobContext jobCtx; - - /** Arguments count. */ - private final int argsCnt; - - /** Future for spawned task. */ - private transient IgniteFuture fut; - - /** - * Create job with specified argument. - * - * @param args Job argument. - */ - VisorGatewayJob(@Nullable Object[] args) { - super(args); - - assert args != null; - - argsCnt = args.length; - } - - /** - * Construct job argument. - * - * @param cls Class. - * @param startIdx Index of first value argument. - */ - @Nullable private Object toJobArgument(Class cls, int startIdx) throws ClassNotFoundException { - String arg = argument(startIdx); - - boolean isList = cls == Collection.class || cls == List.class; - - if (isList || cls == Set.class) { - String items = argument(startIdx + 1); - - if (items == null || "null".equals(items)) - return null; - - Class itemsCls = Class.forName(arg); - - Collection res = isList ? new ArrayList<>() : new HashSet<>(); - - for (String item : items.split(";")) - res.add(toObject(itemsCls, item)); - - return res; - } - - if (cls == IgniteBiTuple.class) { - Class keyCls = Class.forName(arg); - - String valClsName = argument(startIdx + 1); - - assert valClsName != null; - - Class valCls = Class.forName(valClsName); - - return new IgniteBiTuple<>( - toObject(keyCls, argument(startIdx + 2)), - toObject(valCls, argument(startIdx + 3))); - } - - if (cls == Map.class) { - Class keyCls = Class.forName(arg); - - String valClsName = argument(startIdx + 1); - - assert valClsName != null; - - Class valCls = Class.forName(valClsName); - - Map res = new HashMap<>(); - - String entries = argument(startIdx + 2); - - if (entries != null) { - for (String entry : entries.split(";")) { - if (!entry.isEmpty()) { - String[] values = entry.split("="); - - assert values.length >= 1; - - res.put(toObject(keyCls, values[0]), - values.length > 1 ? toObject(valCls, values[1]) : null); - } - } - } - - return res; - } - - if (cls == GridTuple3.class) { - String v2ClsName = argument(startIdx + 1); - String v3ClsName = argument(startIdx + 2); - - assert v2ClsName != null; - assert v3ClsName != null; - - Class v1Cls = Class.forName(arg); - Class v2Cls = Class.forName(v2ClsName); - Class v3Cls = Class.forName(v3ClsName); - - return new GridTuple3<>( - toObject(v1Cls, argument(startIdx + 3)), - toObject(v2Cls, argument(startIdx + 4)), - toObject(v3Cls, argument(startIdx + 5))); - } - - return toObject(cls, arg); - } - - /** - * Construct from string representation to target class. - * - * @param cls Target class. - * @return Object constructed from string. - */ - @Nullable private Object toObject(Class cls, String val) { - if (val == null || "null".equals(val) || "nil".equals(val)) - return null; - - if (String.class == cls) - return val; - - if (Boolean.class == cls || Boolean.TYPE == cls) - return Boolean.parseBoolean(val); - - if (Integer.class == cls || Integer.TYPE == cls) - return Integer.parseInt(val); - - if (Long.class == cls || Long.TYPE == cls) - return Long.parseLong(val); - - if (UUID.class == cls) - return UUID.fromString(val); - - if (IgniteUuid.class == cls) - return IgniteUuid.fromString(val); - - if (Byte.class == cls || Byte.TYPE == cls) - return Byte.parseByte(val); - - if (Short.class == cls || Short.TYPE == cls) - return Short.parseShort(val); - - if (Float.class == cls || Float.TYPE == cls) - return Float.parseFloat(val); - - if (Double.class == cls || Double.TYPE == cls) - return Double.parseDouble(val); - - if (BigDecimal.class == cls) - return new BigDecimal(val); - - if (Collection.class == cls || List.class == cls) - return Arrays.asList(val.split(";")); - - if (Set.class == cls) - return new HashSet<>(Arrays.asList(val.split(";"))); - - if (Object[].class == cls) - return val.split(";"); - - if (byte[].class == cls) { - String[] els = val.split(";"); - - if (els.length == 0 || (els.length == 1 && els[0].isEmpty())) - return ZERO_BYTES; - - byte[] res = new byte[els.length]; - - for (int i = 0; i < els.length; i++) - res[i] = Byte.valueOf(els[i]); - - return res; - } - - if (cls.isEnum()) - return Enum.valueOf(cls, val); - - return val; - } - - /** - * Check if class is not a complex bean. - * - * @param cls Target class. - * @return {@code True} if class is primitive or build-in java type or IgniteUuid. - */ - private static boolean isBuildInObject(Class cls) { - return cls.isPrimitive() || cls.getName().startsWith("java.") || - IgniteUuid.class == cls || IgniteBiTuple.class == cls || GridTuple3.class == cls; - } - - /** - * Extract Class object from arguments. - * - * @param idx Index of argument. - */ - private Class toClass(int idx) throws ClassNotFoundException { - Object arg = argument(idx); // Workaround generics: extract argument as Object to use in String.valueOf(). - - return Class.forName(String.valueOf(arg)); - } - - /** {@inheritDoc} */ - @SuppressWarnings("unchecked") - @Override public Object execute() throws IgniteException { - if (fut != null) - return fut.get(); - - String nidsArg = argument(0); - String taskName = argument(1); - - Object jobArgs = null; - - if (argsCnt > 2) { - String argClsName = argument(2); - - assert argClsName != null; - - try { - Class argCls = Class.forName(argClsName); - - if (argCls == Void.class) - jobArgs = null; - else if (isBuildInObject(argCls)) - jobArgs = toJobArgument(argCls, JOB_ARG_IDX); - else { - int beanArgsCnt = argsCnt - JOB_ARG_IDX; - - for (Constructor ctor : argCls.getDeclaredConstructors()) { - Class[] types = ctor.getParameterTypes(); - - int args = types.length; - - // Length of arguments that required to constructor by influence of nested complex objects. - int needArgs = args; - - for (Class type: types) { - // When constructor required specified types increase length of required arguments. - if (TYPE_ARG_LENGTH.containsKey(type)) - needArgs += TYPE_ARG_LENGTH.get(type); - } - - if (needArgs == beanArgsCnt) { - Object[] initArgs = new Object[args]; - - for (int i = 0, ctrIdx = 0; i < beanArgsCnt; i++, ctrIdx++) { - Class type = types[ctrIdx]; - - // Parse nested complex objects from arguments for specified types. - if (TYPE_ARG_LENGTH.containsKey(type)) { - initArgs[ctrIdx] = toJobArgument(toClass(JOB_ARG_IDX + i), JOB_ARG_IDX + 1 + i); - - i += TYPE_ARG_LENGTH.get(type); - } - // In common case convert value to object. - else { - String val = argument(JOB_ARG_IDX + i); - - initArgs[ctrIdx] = toObject(type, val); - } - } - - ctor.setAccessible(true); - jobArgs = ctor.newInstance(initArgs); - - break; - } - } - - if (jobArgs == null) { - Object[] args = new Object[beanArgsCnt]; - - for (int i = 0; i < beanArgsCnt; i++) - args[i] = argument(i + JOB_ARG_IDX); - - throw new IgniteException("Failed to find constructor for task argument " + - "[taskName=" + taskName + ", argsCnt=" + args.length + - ", args=" + Arrays.toString(args) + "]"); - } - } - } - catch (Exception e) { - throw new IgniteException("Failed to construct job argument [taskName=" + taskName + "]", e); - } - } - - final List nids; - - if (F.isEmpty(nidsArg) || "null".equals(nidsArg)) { - try { - Class taskCls = Class.forName(taskName); - - if (VisorCoordinatorNodeTask.class.isAssignableFrom(taskCls)) { - ClusterNode crd = ignite.context().discovery().discoCache().oldestAliveServerNode(); - - nids = Collections.singletonList(crd.id()); - } - else if (VisorOneNodeTask.class.isAssignableFrom(taskCls)) - nids = Collections.singletonList(ignite.localNode().id()); - else { - Collection nodes = ignite.cluster().nodes(); - - nids = new ArrayList<>(nodes.size()); - - for (ClusterNode node : nodes) - nids.add(node.id()); - } - } - catch (ClassNotFoundException e) { - throw new IgniteException("Failed to find task class:" + taskName, e); - } - } - else { - String[] items = nidsArg.split(";"); - - nids = new ArrayList<>(items.length); - - for (String item : items) { - try { - nids.add(UUID.fromString(item)); - } - catch (IllegalArgumentException ignore) { - ignite.log().warning("Failed to parse node id [taskName=" + taskName + ", nid=" + item + "]"); - } - } - } - - IgniteCompute comp = ignite.compute(ignite.cluster().forNodeIds(nids)); - - fut = comp.executeAsync(taskName, new VisorTaskArgument<>(nids, jobArgs, false)); - - fut.listen(new CI1>() { - @Override public void apply(IgniteFuture f) { - jobCtx.callcc(); - } - }); - - return jobCtx.holdcc(); - } - - @Override - public SecurityPermissionSet requiredPermissions() { - return systemPermissions(ADMIN_OPS); - } - } -} 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 deleted file mode 100644 index e74b54c896c34..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/event/VisorGridDeploymentEvent.java +++ /dev/null @@ -1,106 +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.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; - -/** - * Lightweight counterpart for {@link org.apache.ignite.events.DeploymentEvent}. - */ -public class VisorGridDeploymentEvent extends VisorGridEvent { - /** */ - private static final long serialVersionUID = 0L; - - /** Deployment alias. */ - private String alias; - - /** - * Default constructor. - */ - public VisorGridDeploymentEvent() { - // No-op. - } - - /** - * Create event with given parameters. - * - * @param typeId Event type. - * @param id Event id. - * @param name Event name. - * @param nid Event node ID. - * @param ts Event timestamp. - * @param msg Event message. - * @param shortDisplay Shortened version of {@code toString()} result. - * @param alias Deployment alias. - */ - public VisorGridDeploymentEvent( - int typeId, - IgniteUuid id, - String name, - UUID nid, - long ts, - @Nullable String msg, - String shortDisplay, - String alias - ) { - super(typeId, id, name, nid, ts, msg, shortDisplay); - - this.alias = alias; - } - - /** - * @return Deployment alias. - */ - public String getAlias() { - return alias; - } - - /** {@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); - } -} 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 deleted file mode 100644 index 6f028698f2785..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/event/VisorGridDiscoveryEvent.java +++ /dev/null @@ -1,138 +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.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; - -/** - * Lightweight counterpart for {@link org.apache.ignite.events.DiscoveryEvent}. - */ -public class VisorGridDiscoveryEvent extends VisorGridEvent { - /** */ - private static final long serialVersionUID = 0L; - - /** Node that caused this event to be generated. */ - private UUID evtNodeId; - - /** Node address that caused this event to be generated. */ - private String addr; - - /** Topology version. */ - private long topVer; - - /** - * Default constructor. - */ - public VisorGridDiscoveryEvent() { - // No-op. - } - - /** - * Create event with given parameters. - * - * @param typeId Event type. - * @param id Event id. - * @param name Event name. - * @param nid Event node ID. - * @param ts Event timestamp. - * @param msg Event message. - * @param shortDisplay Shortened version of {@code toString()} result. - * @param evtNodeId Event node id. - * @param addr Event node address. - * @param topVer Topology version. - */ - public VisorGridDiscoveryEvent( - int typeId, - IgniteUuid id, - String name, - UUID nid, - long ts, - @Nullable String msg, - String shortDisplay, - UUID evtNodeId, - String addr, - long topVer - ) { - super(typeId, id, name, nid, ts, msg, shortDisplay); - - this.evtNodeId = evtNodeId; - this.addr = addr; - this.topVer = topVer; - } - - /** - * @return Event node ID. - */ - public UUID getEventNodeId() { - return evtNodeId; - } - - /** - * @return Node address that caused this event to be generated. - */ - public String getAddress() { - return addr; - } - - - /** - * @return Topology version or {@code 0} if configured discovery SPI implementation - * does not support versioning. - **/ - public long getTopologyVersion() { - return topVer; - } - - /** {@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.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); - topVer = in.readLong(); - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorGridDiscoveryEvent.class, this); - } -} 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 deleted file mode 100644 index c1e39988f1f37..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/event/VisorGridEvent.java +++ /dev/null @@ -1,162 +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.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.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 extends VisorDataTransferObject { - /** */ - private static final long serialVersionUID = 0L; - - /** Event type. */ - private int typeId; - - /** Globally unique ID of this event. */ - private IgniteUuid id; - - /** Name of this event. */ - private String name; - - /** Node Id where event occurred and was recorded. */ - private UUID nid; - - /** Event timestamp. */ - private long ts; - - /** Event message. */ - private String msg; - - /** Shortened version of {@code toString()} result. Suitable for humans to read. */ - private String shortDisplay; - - /** - * Default constructor. - */ - public VisorGridEvent() { - // No-op. - } - - /** - * Create event with given parameters. - * - * @param typeId Event type. - * @param id Event id. - * @param name Event name. - * @param nid Event node ID. - * @param ts Event timestamp. - * @param msg Event message. - * @param shortDisplay Shortened version of {@code toString()} result. - */ - public VisorGridEvent(int typeId, IgniteUuid id, String name, UUID nid, long ts, @Nullable String msg, - String shortDisplay) { - this.typeId = typeId; - this.id = id; - this.name = name; - this.nid = nid; - this.ts = ts; - this.msg = msg; - this.shortDisplay = shortDisplay; - } - - /** - * @return Event type. - */ - public int getTypeId() { - return typeId; - } - - /** - * @return Globally unique ID of this event. - */ - public IgniteUuid getId() { - return id; - } - - /** - * @return Name of this event. - */ - public String getName() { - return name; - } - - /** - * @return Node Id where event occurred and was recorded. - */ - public UUID getNid() { - return nid; - } - - /** - * @return Event timestamp. - */ - public long getTimestamp() { - return ts; - } - - /** - * @return Event message. - */ - @Nullable public String getMessage() { - return msg; - } - - /** - * @return Shortened version of result. Suitable for humans to read. - */ - public String getShortDisplay() { - return shortDisplay; - } - - /** {@inheritDoc} */ - @Override protected void writeExternalData(ObjectOutput out) throws IOException { - out.writeInt(typeId); - U.writeIgniteUuid(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.readIgniteUuid(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); - } -} 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 deleted file mode 100644 index e07a3a14a6fe0..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/event/VisorGridEventsLost.java +++ /dev/null @@ -1,54 +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.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; - -/** - * Special event for events lost situations. - */ -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. - */ - public VisorGridEventsLost(UUID nid) { - super(0, IgniteUuid.randomUuid(), "EVT_VISOR_EVENTS_LOST", nid, U.currentTimeMillis(), - "Some Visor events were lost and Visor may show inconsistent results. " + - "Configure your grid to disable not important events.", ""); - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorGridEventsLost.class, this); - } -} 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 deleted file mode 100644 index 4d2fa79507937..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/event/VisorGridJobEvent.java +++ /dev/null @@ -1,151 +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.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; - -/** - * Lightweight counterpart for {@link org.apache.ignite.events.JobEvent} . - */ -public class VisorGridJobEvent extends VisorGridEvent { - /** */ - private static final long serialVersionUID = 0L; - - /** Name of the task that triggered the event. */ - private String taskName; - - /** Name of task class that triggered the event. */ - private String taskClsName; - - /** Task session ID of the task that triggered the event. */ - private IgniteUuid taskSesId; - - /** Job ID. */ - private IgniteUuid jobId; - - /** - * Default constructor. - */ - public VisorGridJobEvent() { - // No-op. - } - - /** - * Create event with given parameters. - * - * @param typeId Event type. - * @param id Event id. - * @param name Event name. - * @param nid Event node ID. - * @param ts Event timestamp. - * @param msg Event message. - * @param shortDisplay Shortened version of {@code toString()} result. - * @param taskName Name of the task that triggered the event. - * @param taskClsName Name of task class that triggered the event. - * @param taskSesId Task session ID of the task that triggered the event. - * @param jobId Job ID. - */ - public VisorGridJobEvent( - int typeId, - IgniteUuid id, - String name, - UUID nid, - long ts, - @Nullable String msg, - String shortDisplay, - String taskName, - String taskClsName, - IgniteUuid taskSesId, - IgniteUuid jobId - ) { - super(typeId, id, name, nid, ts, msg, shortDisplay); - - this.taskName = taskName; - this.taskClsName = taskClsName; - this.taskSesId = taskSesId; - this.jobId = jobId; - } - - /** - * @return Name of the task that triggered the event. - */ - public String getTaskName() { - return taskName; - } - - /** - * @return Name of task class that triggered the event. - */ - public String getTaskClassName() { - return taskClsName; - } - - /** - * @return Task session ID of the task that triggered the event. - */ - public IgniteUuid getTaskSessionId() { - return taskSesId; - } - - /** - * @return Job ID. - */ - public IgniteUuid getJobId() { - return jobId; - } - - /** {@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.writeIgniteUuid(out, taskSesId); - U.writeIgniteUuid(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.readIgniteUuid(in); - jobId = U.readIgniteUuid(in); - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorGridJobEvent.class, this); - } -} 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 deleted file mode 100644 index 0f23c974a338b..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/event/VisorGridTaskEvent.java +++ /dev/null @@ -1,151 +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.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; - -/** - * Lightweight counterpart for {@link org.apache.ignite.events.TaskEvent}. - */ -public class VisorGridTaskEvent extends VisorGridEvent { - /** */ - private static final long serialVersionUID = 0L; - - /** Name of the task that triggered the event. */ - private String taskName; - - /** Name of task class that triggered the event. */ - private String taskClsName; - - /** Task session ID. */ - private IgniteUuid taskSesId; - - /** Whether task was created for system needs. */ - private boolean internal; - - /** - * Default constructor. - */ - public VisorGridTaskEvent() { - // No-op. - } - - /** - * Create event with given parameters. - * - * @param typeId Event type. - * @param id Event id. - * @param name Event name. - * @param nid Event node ID. - * @param ts Event timestamp. - * @param msg Event message. - * @param shortDisplay Shortened version of {@code toString()} result. - * @param taskName Name of the task that triggered the event. - * @param taskClsName Name of task class that triggered the event. - * @param taskSesId Task session ID of the task that triggered the event. - * @param internal Whether task was created for system needs. - */ - public VisorGridTaskEvent( - int typeId, - IgniteUuid id, - String name, - UUID nid, - long ts, - @Nullable String msg, - String shortDisplay, - String taskName, - String taskClsName, - IgniteUuid taskSesId, - boolean internal - ) { - super(typeId, id, name, nid, ts, msg, shortDisplay); - - this.taskName = taskName; - this.taskClsName = taskClsName; - this.taskSesId = taskSesId; - this.internal = internal; - } - - /** - * @return Name of the task that triggered the event. - */ - public String getTaskName() { - return taskName; - } - - /** - * @return Name of task class that triggered the event. - */ - public String getTaskClassName() { - return taskClsName; - } - - /** - * @return Task session ID. - */ - public IgniteUuid getTaskSessionId() { - return taskSesId; - } - - /** - * @return Whether task was created for system needs. - */ - public boolean isInternal() { - return internal; - } - - /** {@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.writeIgniteUuid(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.readIgniteUuid(in); - internal = in.readBoolean(); - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorGridTaskEvent.class, this); - } -} 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 deleted file mode 100644 index 79d0e9315fa87..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/file/VisorFileBlock.java +++ /dev/null @@ -1,144 +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.file; - -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 extends VisorDataTransferObject { - /** */ - private static final long serialVersionUID = 0L; - - /** File path. */ - private String path; - - /** Marker position. */ - private long off; - - /** File size. */ - private long size; - - /** Timestamp of last modification of the file. */ - private long lastModified; - - /** Whether data was zipped. */ - private boolean zipped; - - /** Data bytes. */ - private byte[] data; - - /** - * Default constructor. - */ - public VisorFileBlock() { - // No-op. - } - - /** - * Create file block with given parameters. - * - * @param path File path. - * @param off Marker position. - * @param size File size. - * @param lastModified Timestamp of last modification of the file. - * @param zipped Whether data was zipped. - * @param data Data bytes. - */ - public VisorFileBlock(String path, long off, long size, long lastModified, boolean zipped, byte[] data) { - this.path = path; - this.off = off; - this.size = size; - this.lastModified = lastModified; - this.zipped = zipped; - this.data = data; - } - - /** - * @return File path. - */ - public String getPath() { - return path; - } - - /** - * @return Marker position. - */ - public long getOffset() { - return off; - } - - /** - * @return File size. - */ - public long getSize() { - return size; - } - - /** - * @return Timestamp of last modification of the file. - */ - public long getLastModified() { - return lastModified; - } - - /** - * @return Whether data was zipped. - */ - public boolean isZipped() { - return zipped; - } - - /** - * @return Data bytes. - */ - 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); - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/file/VisorFileBlockTask.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/file/VisorFileBlockTask.java deleted file mode 100644 index ad851cf1babce..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/file/VisorFileBlockTask.java +++ /dev/null @@ -1,89 +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.file; - -import java.io.File; -import java.io.IOException; -import java.net.URISyntaxException; -import java.net.URL; -import java.nio.file.NoSuchFileException; -import org.apache.ignite.internal.processors.task.GridInternal; -import org.apache.ignite.internal.util.typedef.internal.S; -import org.apache.ignite.internal.util.typedef.internal.U; -import org.apache.ignite.internal.visor.VisorEither; -import org.apache.ignite.internal.visor.VisorJob; -import org.apache.ignite.internal.visor.VisorOneNodeTask; - -import static org.apache.ignite.internal.visor.util.VisorTaskUtils.readBlock; - -/** - * Task to read file block. - */ -@GridInternal -public class VisorFileBlockTask extends VisorOneNodeTask> { - /** */ - private static final long serialVersionUID = 0L; - - /** {@inheritDoc} */ - @Override protected VisorFileBlockJob job(VisorFileBlockTaskArg arg) { - return new VisorFileBlockJob(arg, debug); - } - - /** - * Job that read file block on node. - */ - private static class VisorFileBlockJob - extends VisorJob> { - /** */ - private static final long serialVersionUID = 0L; - - /** - * @param arg Descriptor of file block to read. - * @param debug Debug flag. - */ - private VisorFileBlockJob(VisorFileBlockTaskArg arg, boolean debug) { - super(arg, debug); - } - - /** {@inheritDoc} */ - @Override protected VisorEither run(VisorFileBlockTaskArg arg) { - try { - URL url = U.resolveIgniteUrl(arg.getPath()); - - if (url == null) - return new VisorEither<>(new NoSuchFileException("File path not found: " + arg.getPath())); - - VisorFileBlock block = readBlock( - new File(url.toURI()), arg.getOffset(), arg.getBlockSize(), arg.getLastModified()); - - return new VisorEither<>(block); - } - catch (IOException e) { - return new VisorEither<>(e); - } - catch (URISyntaxException ignored) { - return new VisorEither<>(new NoSuchFileException("File path not found: " + arg.getPath())); - } - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorFileBlockJob.class, this); - } - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/file/VisorFileBlockTaskArg.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/file/VisorFileBlockTaskArg.java deleted file mode 100644 index de41c4edada92..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/file/VisorFileBlockTaskArg.java +++ /dev/null @@ -1,114 +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.file; - -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; - -/** - * Arguments for {@link VisorFileBlockTask} - */ -public class VisorFileBlockTaskArg extends VisorDataTransferObject { - /** */ - private static final long serialVersionUID = 0L; - - /** Log file path. */ - private String path; - - /** Log file offset. */ - private long off; - - /** Block size. */ - private int blockSz; - - /** Log file last modified timestamp. */ - private long lastModified; - - /** - * Default constructor. - */ - public VisorFileBlockTaskArg() { - // No-op. - } - - /** - * @param path Log file path. - * @param off Offset in file. - * @param blockSz Block size. - * @param lastModified Log file last modified timestamp. - */ - public VisorFileBlockTaskArg(String path, long off, int blockSz, long lastModified) { - this.path = path; - this.off = off; - this.blockSz = blockSz; - this.lastModified = lastModified; - } - - /** - * @return Log file path. - */ - public String getPath() { - return path; - } - - /** - * @return Log file offset. - */ - public long getOffset() { - return off; - } - - /** - * @return Block size - */ - public int getBlockSize() { - return blockSz; - } - - /** - * @return Log file last modified timestamp. - */ - public long getLastModified() { - return lastModified; - } - - /** {@inheritDoc} */ - @Override protected void writeExternalData(ObjectOutput out) throws IOException { - U.writeString(out, path); - out.writeLong(off); - out.writeInt(blockSz); - out.writeLong(lastModified); - } - - /** {@inheritDoc} */ - @Override protected void readExternalData(byte protoVer, ObjectInput in) throws IOException, ClassNotFoundException { - path = U.readString(in); - off = in.readLong(); - blockSz = in.readInt(); - lastModified = in.readLong(); - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorFileBlockTaskArg.class, this); - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/file/VisorFileBlockTaskResult.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/file/VisorFileBlockTaskResult.java deleted file mode 100644 index b888f6d17bbe6..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/file/VisorFileBlockTaskResult.java +++ /dev/null @@ -1,87 +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.file; - -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.visor.VisorDataTransferObject; - -/** - * Result for file block operation. - */ -public class VisorFileBlockTaskResult extends VisorDataTransferObject { - /** */ - private static final long serialVersionUID = 0L; - - /** Exception on reading of block. */ - private IOException ex; - - /** Read file block. */ - private VisorFileBlock block; - - /** - * Default constructor. - */ - public VisorFileBlockTaskResult() { - // No-op. - } - - /** - * Create log search result with given parameters. - * - * @param ex Exception on reading of block. - * @param block Read file block. - */ - public VisorFileBlockTaskResult(IOException ex, VisorFileBlock block) { - this.ex = ex; - this.block = block; - } - - /** - * @return Exception on reading of block. - */ - public IOException getException() { - return ex; - } - - /** - * @return Read file block. - */ - public VisorFileBlock getBlock() { - return block; - } - - /** {@inheritDoc} */ - @Override protected void writeExternalData(ObjectOutput out) throws IOException { - out.writeObject(ex); - out.writeObject(block); - } - - /** {@inheritDoc} */ - @Override protected void readExternalData(byte protoVer, ObjectInput in) throws IOException, ClassNotFoundException { - ex = (IOException)in.readObject(); - block = (VisorFileBlock)in.readObject(); - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorFileBlockTaskResult.class, this); - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/file/VisorLatestTextFilesTask.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/file/VisorLatestTextFilesTask.java deleted file mode 100644 index 3b8defeb9145a..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/file/VisorLatestTextFilesTask.java +++ /dev/null @@ -1,97 +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.file; - -import java.io.File; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -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.VisorOneNodeTask; -import org.apache.ignite.internal.visor.log.VisorLogFile; -import org.jetbrains.annotations.Nullable; - -import static org.apache.ignite.internal.visor.util.VisorTaskUtils.LOG_FILES_COUNT_LIMIT; -import static org.apache.ignite.internal.visor.util.VisorTaskUtils.matchedFiles; -import static org.apache.ignite.internal.visor.util.VisorTaskUtils.resolveIgnitePath; - -/** - * Get list files matching filter. - */ -@GridInternal -public class VisorLatestTextFilesTask extends VisorOneNodeTask> { - /** */ - private static final long serialVersionUID = 0L; - - /** {@inheritDoc} */ - @Override protected VisorLatestTextFilesJob job(VisorLatestTextFilesTaskArg arg) { - return new VisorLatestTextFilesJob(arg, debug); - } - - /** - * Job that gets list of files. - */ - private static class VisorLatestTextFilesJob extends VisorJob> { - /** */ - private static final long serialVersionUID = 0L; - - /** - * @param arg Folder and regexp. - * @param debug Debug flag. - */ - private VisorLatestTextFilesJob(VisorLatestTextFilesTaskArg arg, boolean debug) { - super(arg, debug); - } - - /** {@inheritDoc} */ - @Nullable @Override protected Collection run(final VisorLatestTextFilesTaskArg arg) { - String path = arg.getPath(); - String regexp = arg.getRegexp(); - - assert path != null; - assert regexp != null; - - try { - File folder = resolveIgnitePath(path); - - if (folder == null) - return null; - - List files = matchedFiles(folder, regexp); - - if (files.isEmpty()) - return null; - - if (files.size() > LOG_FILES_COUNT_LIMIT) - files = new ArrayList<>(files.subList(0, LOG_FILES_COUNT_LIMIT)); - - return files; - } - catch (Exception ignored) { - return null; - } - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorLatestTextFilesJob.class, this); - } - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/file/VisorLatestTextFilesTaskArg.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/file/VisorLatestTextFilesTaskArg.java deleted file mode 100644 index d0bc99dadb765..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/file/VisorLatestTextFilesTaskArg.java +++ /dev/null @@ -1,86 +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.file; - -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; - -/** - * Arguments for {@link VisorLatestTextFilesTask} - */ -public class VisorLatestTextFilesTaskArg extends VisorDataTransferObject { - /** */ - private static final long serialVersionUID = 0L; - - /** Folder path to search files. */ - private String path; - - /** Pattern to match file names. */ - private String regexp; - - /** - * Default constructor. - */ - public VisorLatestTextFilesTaskArg() { - // No-op. - } - - /** - * @param path Folder path to search in files. - * @param regexp Pattern to match file names. - */ - public VisorLatestTextFilesTaskArg(String path, String regexp) { - this.path = path; - this.regexp = regexp; - } - - /** - * @return Folder path to search in files. - */ - public String getPath() { - return path; - } - - /** - * @return Pattern to match file names. - */ - public String getRegexp() { - return regexp; - } - - /** {@inheritDoc} */ - @Override protected void writeExternalData(ObjectOutput out) throws IOException { - U.writeString(out, path); - U.writeString(out, regexp); - } - - /** {@inheritDoc} */ - @Override protected void readExternalData(byte protoVer, ObjectInput in) throws IOException, ClassNotFoundException { - path = U.readString(in); - regexp = U.readString(in); - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorLatestTextFilesTaskArg.class, this); - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/igfs/VisorIgfs.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/igfs/VisorIgfs.java deleted file mode 100644 index ef568d8129356..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/igfs/VisorIgfs.java +++ /dev/null @@ -1,117 +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.igfs; - -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; - -/** - * Data transfer object. - */ -@Deprecated -public class VisorIgfs extends VisorDataTransferObject { - /** */ - private static final long serialVersionUID = 0L; - - /** IGFS instance name. */ - private String name; - - /** IGFS instance working mode. */ - private VisorIgfsMode mode; - - /** IGFS metrics. */ - private VisorIgfsMetrics metrics; - - /** Whether IGFS has configured secondary file system. */ - private boolean secondaryFsConfigured; - - /** - * Default constructor. - */ - public VisorIgfs() { - // No-op. - } - - /** - * Create IGFS configuration transfer object. - * - * @param name IGFS instance name. - * @param mode IGFS instance working mode. - * @param metrics IGFS metrics. - * @param secondaryFsConfigured Whether IGFS has configured secondary file system. - */ - public VisorIgfs(String name, VisorIgfsMode mode, VisorIgfsMetrics metrics, boolean secondaryFsConfigured) { - this.name = name; - this.mode = mode; - this.metrics = metrics; - this.secondaryFsConfigured = secondaryFsConfigured; - } - - /** - * @return IGFS instance name. - */ - public String getName() { - return name; - } - - /** - * @return IGFS instance working mode. - */ - public VisorIgfsMode getMode() { - return mode; - } - - /** - * @return IGFS metrics. - */ - public VisorIgfsMetrics getMetrics() { - return metrics; - } - - /** - * @return Whether IGFS has configured secondary file system. - */ - public boolean isSecondaryFileSystemConfigured() { - return secondaryFsConfigured; - } - - /** {@inheritDoc} */ - @Override protected void writeExternalData(ObjectOutput out) throws IOException { - U.writeString(out, name); - U.writeEnum(out, mode); - out.writeObject(metrics); - out.writeBoolean(secondaryFsConfigured); - } - - /** {@inheritDoc} */ - @Override protected void readExternalData(byte protoVer, ObjectInput in) throws IOException, ClassNotFoundException { - name = U.readString(in); - mode = VisorIgfsMode.fromOrdinal(in.readByte()); - metrics = (VisorIgfsMetrics)in.readObject(); - secondaryFsConfigured = in.readBoolean(); - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorIgfs.class, this); - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/igfs/VisorIgfsEndpoint.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/igfs/VisorIgfsEndpoint.java deleted file mode 100644 index f0748caecdaf6..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/igfs/VisorIgfsEndpoint.java +++ /dev/null @@ -1,134 +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.igfs; - -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; -import org.jetbrains.annotations.Nullable; - -/** - * IGFS endpoint descriptor. - */ -@Deprecated -public class VisorIgfsEndpoint extends VisorDataTransferObject { - /** */ - private static final long serialVersionUID = 0L; - - /** IGFS name. */ - private String igfsName; - - /** Grid name. */ - private String gridName; - - /** Host address / name. */ - private String hostName; - - /** Port number. */ - private int port; - - /** - * Default constructor. - */ - public VisorIgfsEndpoint() { - // No-op. - } - - /** - * Create IGFS endpoint descriptor with given parameters. - * - * @param igfsName IGFS name. - * @param gridName Grid name. - * @param hostName Host address / name. - * @param port Port number. - */ - public VisorIgfsEndpoint(@Nullable String igfsName, String gridName, @Nullable String hostName, int port) { - this.igfsName = igfsName; - this.gridName = gridName; - this.hostName = hostName; - this.port = port; - } - - /** - * @return IGFS name. - */ - @Nullable public String getIgfsName() { - return igfsName; - } - - /** - * @return Grid name. - */ - public String getGridName() { - return gridName; - } - - /** - * @return Host address / name. - */ - @Nullable public String getHostName() { - return hostName; - } - - /** - * @return Port number. - */ - public int getPort() { - return port; - } - - /** - * @return URI Authority - */ - public String getAuthority() { - String addr = hostName + ":" + port; - - if (igfsName == null && gridName == null) - return addr; - else if (igfsName == null) - return gridName + "@" + addr; - else if (gridName == null) - return igfsName + "@" + addr; - else - return igfsName + ":" + gridName + "@" + addr; - } - - /** {@inheritDoc} */ - @Override protected void writeExternalData(ObjectOutput out) throws IOException { - U.writeString(out, igfsName); - U.writeString(out, gridName); - U.writeString(out, hostName); - out.writeInt(port); - } - - /** {@inheritDoc} */ - @Override protected void readExternalData(byte protoVer, ObjectInput in) throws IOException, ClassNotFoundException { - igfsName = U.readString(in); - gridName = U.readString(in); - hostName = U.readString(in); - port = in.readInt(); - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorIgfsEndpoint.class, this); - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/igfs/VisorIgfsFormatTask.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/igfs/VisorIgfsFormatTask.java deleted file mode 100644 index 231c84598b0c0..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/igfs/VisorIgfsFormatTask.java +++ /dev/null @@ -1,67 +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.igfs; - -import org.apache.ignite.IgniteException; -import org.apache.ignite.internal.processors.task.GridInternal; -import org.apache.ignite.internal.processors.task.GridVisorManagementTask; -import org.apache.ignite.internal.util.typedef.internal.S; -import org.apache.ignite.internal.visor.VisorJob; -import org.apache.ignite.internal.visor.VisorOneNodeTask; - -/** - * Format IGFS instance. - */ -@GridInternal -@GridVisorManagementTask -@Deprecated -public class VisorIgfsFormatTask extends VisorOneNodeTask { - /** */ - private static final long serialVersionUID = 0L; - - /** {@inheritDoc} */ - @Override protected VisorIgfsFormatJob job(VisorIgfsFormatTaskArg arg) { - return new VisorIgfsFormatJob(arg, debug); - } - - /** - * Job that format IGFS. - */ - private static class VisorIgfsFormatJob extends VisorJob { - /** */ - private static final long serialVersionUID = 0L; - - /** - * @param arg IGFS name to format. - * @param debug Debug flag. - */ - private VisorIgfsFormatJob(VisorIgfsFormatTaskArg arg, boolean debug) { - super(arg, debug); - } - - /** {@inheritDoc} */ - @Override protected Void run(VisorIgfsFormatTaskArg arg) { - throw new IgniteException("IGFS operations are not supported in current version of Ignite"); - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorIgfsFormatJob.class, this); - } - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/igfs/VisorIgfsFormatTaskArg.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/igfs/VisorIgfsFormatTaskArg.java deleted file mode 100644 index c0a04fc55fcc8..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/igfs/VisorIgfsFormatTaskArg.java +++ /dev/null @@ -1,73 +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.igfs; - -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; - -/** - * Argument for {@link VisorIgfsFormatTask}. - */ -@Deprecated -public class VisorIgfsFormatTaskArg extends VisorDataTransferObject { - /** */ - private static final long serialVersionUID = 0L; - - /** IGFS name. */ - private String igfsName; - - /** - * Default constructor. - */ - public VisorIgfsFormatTaskArg() { - // No-op. - } - - /** - * @param igfsName IGFS name. - */ - public VisorIgfsFormatTaskArg(String igfsName) { - this.igfsName = igfsName; - } - - /** - * @return IGFS name. - */ - public String getIgfsName() { - return igfsName; - } - - /** {@inheritDoc} */ - @Override protected void writeExternalData(ObjectOutput out) throws IOException { - U.writeString(out, igfsName); - } - - /** {@inheritDoc} */ - @Override protected void readExternalData(byte protoVer, ObjectInput in) throws IOException, ClassNotFoundException { - igfsName = U.readString(in); - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorIgfsFormatTaskArg.class, this); - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/igfs/VisorIgfsMetrics.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/igfs/VisorIgfsMetrics.java deleted file mode 100644 index a412ecb2cdfd5..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/igfs/VisorIgfsMetrics.java +++ /dev/null @@ -1,270 +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.igfs; - -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.visor.VisorDataTransferObject; - -/** - * Data transfer object. - */ -@Deprecated -public class VisorIgfsMetrics extends VisorDataTransferObject { - /** */ - private static final long serialVersionUID = 0L; - - /** Maximum amount of data that can be stored on local node. */ - private long totalSpaceSz; - - /** Local used space in bytes on local node. */ - private long usedSpaceSz; - - /** Number of directories created in file system. */ - private int foldersCnt; - - /** Number of files stored in file system. */ - private int filesCnt; - - /** Number of files that are currently opened for reading on local node. */ - private int filesOpenedForRd; - - /** Number of files that are currently opened for writing on local node. */ - private int filesOpenedForWrt; - - /** Total blocks read, local and remote. */ - private long blocksRd; - - /** Total remote blocks read. */ - private long blocksRdRmt; - - /** Total blocks write, local and remote. */ - private long blocksWrt; - - /** Total remote blocks write. */ - private long blocksWrtRmt; - - /** Total bytes read. */ - private long bytesRd; - - /** Total bytes read time. */ - private long bytesRdTm; - - /** Total bytes write. */ - private long bytesWrt; - - /** Total bytes write time. */ - private long bytesWrtTm; - - /** - * Create data transfer object for given IGFS metrics. - */ - public VisorIgfsMetrics() { - // No-op. - } - - /** - * Add given metrics. - * - * @param m Metrics to add. - * @return Self for method chaining. - */ - public VisorIgfsMetrics add(VisorIgfsMetrics m) { - assert m != null; - - totalSpaceSz += m.totalSpaceSz; - usedSpaceSz += m.usedSpaceSz; - foldersCnt += m.foldersCnt; - filesCnt += m.filesCnt; - filesOpenedForRd += m.filesOpenedForRd; - filesOpenedForWrt += m.filesOpenedForWrt; - blocksRd += m.blocksRd; - blocksRdRmt += m.blocksRdRmt; - blocksWrt += m.blocksWrt; - blocksWrtRmt += m.blocksWrtRmt; - bytesRd += m.bytesRd; - bytesRdTm += m.bytesRdTm; - bytesWrt += m.bytesWrt; - bytesWrtTm += m.bytesWrtTm; - - return this; - } - - /** - * Aggregate metrics. - * - * @param n Nodes count. - * @return Self for method chaining. - */ - public VisorIgfsMetrics aggregate(int n) { - if (n > 0) { - foldersCnt /= n; - filesCnt /= n; - } - - return this; - } - - /** - * @return Maximum amount of data that can be stored on local node. - */ - public long getTotalSpaceSize() { - return totalSpaceSz; - } - - /** - * @return Local used space in bytes on local node. - */ - public long getUsedSpaceSize() { - return usedSpaceSz; - } - - /** - * @return Local free space in bytes on local node. - */ - public long getFreeSpaceSize() { - return totalSpaceSz - usedSpaceSz; - } - - /** - * @return Number of directories created in file system. - */ - public int getFoldersCount() { - return foldersCnt; - } - - /** - * @return Number of files stored in file system. - */ - public int getFilesCount() { - return filesCnt; - } - - /** - * @return Number of files that are currently opened for reading on local node. - */ - public int getFilesOpenedForRead() { - return filesOpenedForRd; - } - - /** - * @return Number of files that are currently opened for writing on local node. - */ - public int getFilesOpenedForWrite() { - return filesOpenedForWrt; - } - - /** - * @return Total blocks read, local and remote. - */ - public long getBlocksRead() { - return blocksRd; - } - - /** - * @return Total remote blocks read. - */ - public long getBlocksReadRemote() { - return blocksRdRmt; - } - - /** - * @return Total blocks write, local and remote. - */ - public long getBlocksWritten() { - return blocksWrt; - } - - /** - * @return Total remote blocks write. - */ - public long getBlocksWrittenRemote() { - return blocksWrtRmt; - } - - /** - * @return Total bytes read. - */ - public long getBytesRead() { - return bytesRd; - } - - /** - * @return Total bytes read time. - */ - public long getBytesReadTime() { - return bytesRdTm; - } - - /** - * @return Total bytes write. - */ - public long getBytesWritten() { - return bytesWrt; - } - - /** - * @return Total bytes write time. - */ - public long getBytesWriteTime() { - return bytesWrtTm; - } - - /** {@inheritDoc} */ - @Override protected void writeExternalData(ObjectOutput out) throws IOException { - out.writeLong(totalSpaceSz); - out.writeLong(usedSpaceSz); - out.writeInt(foldersCnt); - out.writeInt(filesCnt); - out.writeInt(filesOpenedForRd); - out.writeInt(filesOpenedForWrt); - out.writeLong(blocksRd); - out.writeLong(blocksRdRmt); - out.writeLong(blocksWrt); - out.writeLong(blocksWrtRmt); - out.writeLong(bytesRd); - out.writeLong(bytesRdTm); - out.writeLong(bytesWrt); - out.writeLong(bytesWrtTm); - } - - /** {@inheritDoc} */ - @Override protected void readExternalData(byte protoVer, ObjectInput in) throws IOException, ClassNotFoundException { - totalSpaceSz = in.readLong(); - usedSpaceSz = in.readLong(); - foldersCnt = in.readInt(); - filesCnt = in.readInt(); - filesOpenedForRd = in.readInt(); - filesOpenedForWrt = in.readInt(); - blocksRd = in.readLong(); - blocksRdRmt = in.readLong(); - blocksWrt = in.readLong(); - blocksWrtRmt = in.readLong(); - bytesRd = in.readLong(); - bytesRdTm = in.readLong(); - bytesWrt = in.readLong(); - bytesWrtTm = in.readLong(); - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorIgfsMetrics.class, this); - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/igfs/VisorIgfsMode.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/igfs/VisorIgfsMode.java deleted file mode 100644 index b011dc6d2067f..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/igfs/VisorIgfsMode.java +++ /dev/null @@ -1,72 +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.igfs; - -import org.jetbrains.annotations.Nullable; - -/** - * {@code IGFS} mode defining interactions with underlying secondary Hadoop file system. - * Secondary Hadoop file system is provided for pass-through, write-through, and - * read-through purposes. - */ -@Deprecated -public enum VisorIgfsMode { - /** - * In this mode IGFS will not delegate to secondary Hadoop file system and will - * cache all the files in memory only. - */ - PRIMARY, - - /** - * In this mode IGFS will not cache any files in memory and will only pass them - * through to secondary Hadoop file system. If this mode is enabled, then - * secondary Hadoop file system must be configured. - */ - PROXY, - - /** - * In this mode {@code IGFS} will cache files locally and also synchronously - * write them through to secondary Hadoop file system. - *

- * If secondary Hadoop file system is not configured, then this mode behaves like - * {@link #PRIMARY} mode. - */ - DUAL_SYNC, - - /** - * In this mode {@code IGFS} will cache files locally and also asynchronously - * write them through to secondary Hadoop file system. - *

- * If secondary Hadoop file system is not configured, then this mode behaves like - * {@link #PRIMARY} mode. - */ - DUAL_ASYNC; - - /** Enumerated values. */ - private static final VisorIgfsMode[] VALS = values(); - - /** - * Efficiently gets enumerated value from its ordinal. - * - * @param ord Ordinal value. - * @return Enumerated value or {@code null} if ordinal out of range. - */ - @Nullable public static VisorIgfsMode fromOrdinal(int ord) { - return ord >= 0 && ord < VALS.length ? VALS[ord] : null; - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/igfs/VisorIgfsProfiler.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/igfs/VisorIgfsProfiler.java deleted file mode 100644 index 8fbf5097eb002..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/igfs/VisorIgfsProfiler.java +++ /dev/null @@ -1,88 +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.igfs; - -import java.util.Collections; -import java.util.List; -import org.apache.ignite.internal.util.typedef.F; - -/** - * Various global constants for IGFS profiler. - */ -@Deprecated -public class VisorIgfsProfiler { - /** Default file block size to calculate uniformity. */ - public static final int UNIFORMITY_DFLT_BLOCK_SIZE = 4096; - - /** Default number of blocks to split file for uniformity calculations. */ - public static final int UNIFORMITY_BLOCKS = 100; - - /** - * Aggregate IGFS profiler entries. - * - * @param entries Entries to sum. - * @return Single aggregated entry. - */ - public static VisorIgfsProfilerEntry aggregateIgfsProfilerEntries(List entries) { - assert !F.isEmpty(entries); - - if (entries.size() == 1) - return entries.get(0); // No need to aggregate. - else { - String path = entries.get(0).getPath(); - - Collections.sort(entries, VisorIgfsProfilerEntry.ENTRY_TIMESTAMP_COMPARATOR); - - long ts = 0; - long size = 0; - long bytesRead = 0; - long readTime = 0; - long userReadTime = 0; - long bytesWritten = 0; - long writeTime = 0; - long userWriteTime = 0; - VisorIgfsMode mode = null; - VisorIgfsProfilerUniformityCounters counters = new VisorIgfsProfilerUniformityCounters(); - - for (VisorIgfsProfilerEntry entry : entries) { - // Take last timestamp. - ts = entry.getTimestamp(); - - // Take last size. - size = entry.getSize(); - - // Take last mode. - mode = entry.getMode(); - - // Aggregate metrics. - bytesRead += entry.getBytesRead(); - readTime += entry.getReadTime(); - userReadTime += entry.getUserReadTime(); - bytesWritten += entry.getBytesWritten(); - writeTime += entry.getWriteTime(); - userWriteTime += entry.getUserWriteTime(); - - counters.aggregate(entry.getCounters()); - } - - return new VisorIgfsProfilerEntry(path, ts, mode, size, bytesRead, readTime, userReadTime, - bytesWritten, writeTime, userWriteTime, counters); - } - } - -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/igfs/VisorIgfsProfilerClearTask.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/igfs/VisorIgfsProfilerClearTask.java deleted file mode 100644 index 2c24796ca3453..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/igfs/VisorIgfsProfilerClearTask.java +++ /dev/null @@ -1,70 +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.igfs; - -import org.apache.ignite.IgniteException; -import org.apache.ignite.internal.processors.task.GridInternal; -import org.apache.ignite.internal.processors.task.GridVisorManagementTask; -import org.apache.ignite.internal.util.typedef.internal.S; -import org.apache.ignite.internal.visor.VisorJob; -import org.apache.ignite.internal.visor.VisorOneNodeTask; - - -/** - * Remove all IGFS profiler logs. - */ -@GridInternal -@GridVisorManagementTask -@Deprecated -public class VisorIgfsProfilerClearTask extends VisorOneNodeTask { - /** */ - private static final long serialVersionUID = 0L; - - /** {@inheritDoc} */ - @Override protected VisorIgfsProfilerClearJob job(VisorIgfsProfilerClearTaskArg arg) { - return new VisorIgfsProfilerClearJob(arg, debug); - } - - /** - * Job to clear profiler logs. - */ - private static class VisorIgfsProfilerClearJob extends VisorJob { - /** */ - private static final long serialVersionUID = 0L; - - /** - * Create job with given argument. - * - * @param arg Job argument. - * @param debug Debug flag. - */ - private VisorIgfsProfilerClearJob(VisorIgfsProfilerClearTaskArg arg, boolean debug) { - super(arg, debug); - } - - /** {@inheritDoc} */ - @Override protected VisorIgfsProfilerClearTaskResult run(VisorIgfsProfilerClearTaskArg arg) { - throw new IgniteException("IGFS operations are not supported in current version of Ignite"); - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorIgfsProfilerClearJob.class, this); - } - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/igfs/VisorIgfsProfilerClearTaskArg.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/igfs/VisorIgfsProfilerClearTaskArg.java deleted file mode 100644 index fab11886f4407..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/igfs/VisorIgfsProfilerClearTaskArg.java +++ /dev/null @@ -1,73 +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.igfs; - -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; - -/** - * Argument for {@link VisorIgfsProfilerClearTask}. - */ -@Deprecated -public class VisorIgfsProfilerClearTaskArg extends VisorDataTransferObject { - /** */ - private static final long serialVersionUID = 0L; - - /** IGFS name. */ - private String igfsName; - - /** - * Default constructor. - */ - public VisorIgfsProfilerClearTaskArg() { - // No-op. - } - - /** - * @param igfsName IGFS name. - */ - public VisorIgfsProfilerClearTaskArg(String igfsName) { - this.igfsName = igfsName; - } - - /** - * @return IGFS name. - */ - public String getIgfsName() { - return igfsName; - } - - /** {@inheritDoc} */ - @Override protected void writeExternalData(ObjectOutput out) throws IOException { - U.writeString(out, igfsName); - } - - /** {@inheritDoc} */ - @Override protected void readExternalData(byte protoVer, ObjectInput in) throws IOException, ClassNotFoundException { - igfsName = U.readString(in); - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorIgfsProfilerClearTaskArg.class, this); - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/igfs/VisorIgfsProfilerClearTaskResult.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/igfs/VisorIgfsProfilerClearTaskResult.java deleted file mode 100644 index 97e2c22979834..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/igfs/VisorIgfsProfilerClearTaskResult.java +++ /dev/null @@ -1,86 +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.igfs; - -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.visor.VisorDataTransferObject; - -/** - * Result for {@link VisorIgfsProfilerClearTask}. - */ -@Deprecated -public class VisorIgfsProfilerClearTaskResult extends VisorDataTransferObject { - /** */ - private static final long serialVersionUID = 0L; - - /** Count of deleted files. */ - private int deleted; - - /** Count of not deleted files. */ - private int notDeleted; - - /** - * Default constructor. - */ - public VisorIgfsProfilerClearTaskResult() { - // No-op. - } - - /** - * @param deleted Count of deleted files. - * @param notDeleted Count of not deleted files. - */ - public VisorIgfsProfilerClearTaskResult(int deleted, int notDeleted) { - this.deleted = deleted; - this.notDeleted = notDeleted; - } - - /** - * @return Count of deleted files. - */ - public Integer getDeleted() { - return deleted; - } - - /** - * @return Count of not deleted files. - */ - public Integer getNotDeleted() { - return notDeleted; - } - - /** {@inheritDoc} */ - @Override protected void writeExternalData(ObjectOutput out) throws IOException { - out.writeInt(deleted); - out.writeInt(notDeleted); - } - - /** {@inheritDoc} */ - @Override protected void readExternalData(byte protoVer, ObjectInput in) throws IOException, ClassNotFoundException { - deleted = in.readInt(); - notDeleted = in.readInt(); - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorIgfsProfilerClearTaskResult.class, this); - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/igfs/VisorIgfsProfilerEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/igfs/VisorIgfsProfilerEntry.java deleted file mode 100644 index ece22331b0f39..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/igfs/VisorIgfsProfilerEntry.java +++ /dev/null @@ -1,284 +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.igfs; - -import java.io.IOException; -import java.io.ObjectInput; -import java.io.ObjectOutput; -import java.util.Comparator; -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; - -/** - * Visor IGFS profiler information about one file. - */ -@Deprecated -public class VisorIgfsProfilerEntry extends VisorDataTransferObject { - /** */ - private static final long serialVersionUID = 0L; - - /** Timestamp comparator. */ - public static final Comparator ENTRY_TIMESTAMP_COMPARATOR = - new Comparator() { - @Override public int compare(VisorIgfsProfilerEntry a, VisorIgfsProfilerEntry b) { - return Long.compare(a.ts, b.ts); - } - }; - - /** Path to file. */ - private String path; - - /** Timestamp of last file operation. */ - private long ts; - - /** IGFS mode. */ - private VisorIgfsMode mode; - - /** File size. */ - private long size; - - /** How many bytes were read. */ - private long bytesRead; - - /** How long read take. */ - private long readTime; - - /** User read time. */ - private long userReadTime; - - /** How many bytes were written. */ - private long bytesWritten; - - /** How long write take. */ - private long writeTime; - - /** User write read time. */ - private long userWriteTime; - - /** Calculated uniformity. */ - private double uniformity = -1; - - /** Counters for uniformity calculation. */ - private VisorIgfsProfilerUniformityCounters counters; - - /** Read speed in bytes per second or {@code -1} if speed not available. */ - private long readSpeed; - - /** Write speed in bytes per second or {@code -1} if speed not available. */ - private long writeSpeed; - - /** - * Default constructor. - */ - public VisorIgfsProfilerEntry() { - // No-op. - } - - /** Create data transfer object with given parameters. */ - public VisorIgfsProfilerEntry( - String path, - long ts, - VisorIgfsMode mode, - long size, - long bytesRead, - long readTime, - long userReadTime, - long bytesWritten, - long writeTime, - long userWriteTime, - VisorIgfsProfilerUniformityCounters counters - ) { - assert counters != null; - - this.path = path; - this.ts = ts; - this.mode = mode; - this.size = size; - this.bytesRead = bytesRead; - this.readTime = readTime; - this.userReadTime = userReadTime; - this.bytesWritten = bytesWritten; - this.writeTime = writeTime; - this.userWriteTime = userWriteTime; - this.counters = counters; - - readSpeed = speed(bytesRead, readTime); - writeSpeed = speed(bytesWritten, writeTime); - } - - /** - * Calculate speed of bytes processing. - * - * @param bytes How many bytes were processed. - * @param time How long processing take (in nanoseconds). - * @return Speed of processing in bytes per second or {@code -1} if speed not available. - */ - private static long speed(long bytes, long time) { - if (time > 0) { - double bytesScaled = bytes * 100000d; - double timeScaled = time / 10000d; - - return (long)(bytesScaled / timeScaled); - } - else - return -1L; - } - - /** - * @return Path to file. - */ - public String getPath() { - return path; - } - - /** - * @return Timestamp of last file operation. - */ - public long getTimestamp() { - return ts; - } - - /** - * @return IGFS mode. - */ - public VisorIgfsMode getMode() { - return mode; - } - - /** - * @return File size. - */ - public long getSize() { - return size; - } - - /** - * @return How many bytes were read. - */ - public long getBytesRead() { - return bytesRead; - } - - /** - * @return How long read take. - */ - public long getReadTime() { - return readTime; - } - - /** - * @return User read time. - */ - public long getUserReadTime() { - return userReadTime; - } - - /** - * @return How many bytes were written. - */ - public long getBytesWritten() { - return bytesWritten; - } - - /** - * @return How long write take. - */ - public long getWriteTime() { - return writeTime; - } - - /** - * @return User write read time. - */ - public long getUserWriteTime() { - return userWriteTime; - } - - /** - * @return Calculated uniformity. - */ - public double getUniformity() { - if (uniformity < 0) - uniformity = counters.calc(); - - return uniformity; - } - - /** - * @return Counters for uniformity calculation. - */ - public VisorIgfsProfilerUniformityCounters getCounters() { - return counters; - } - - /** - * @return Read speed in bytes per second or {@code -1} if speed not available. - */ - public long getReadSpeed() { - return readSpeed; - } - - /** - * @return Write speed in bytes per second or {@code -1} if speed not available. - */ - public long getWriteSpeed() { - return writeSpeed; - } - - /** {@inheritDoc} */ - @Override protected void writeExternalData(ObjectOutput out) throws IOException { - U.writeString(out, path); - out.writeLong(ts); - U.writeEnum(out, mode); - out.writeLong(size); - out.writeLong(bytesRead); - out.writeLong(readTime); - out.writeLong(userReadTime); - out.writeLong(bytesWritten); - out.writeLong(writeTime); - out.writeLong(userWriteTime); - out.writeDouble(uniformity); - out.writeObject(counters); - out.writeLong(readSpeed); - out.writeLong(writeSpeed); - } - - /** {@inheritDoc} */ - @Override protected void readExternalData(byte protoVer, ObjectInput in) throws IOException, ClassNotFoundException { - path = U.readString(in); - ts = in.readLong(); - mode = VisorIgfsMode.fromOrdinal(in.readByte()); - size = in.readLong(); - bytesRead = in.readLong(); - readTime = in.readLong(); - userReadTime = in.readLong(); - bytesWritten = in.readLong(); - writeTime = in.readLong(); - userWriteTime = in.readLong(); - uniformity = in.readDouble(); - counters = (VisorIgfsProfilerUniformityCounters)in.readObject(); - readSpeed = in.readLong(); - writeSpeed = in.readLong(); - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorIgfsProfilerEntry.class, this); - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/igfs/VisorIgfsProfilerTask.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/igfs/VisorIgfsProfilerTask.java deleted file mode 100644 index 187171aab5e0d..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/igfs/VisorIgfsProfilerTask.java +++ /dev/null @@ -1,71 +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.igfs; - -import java.util.List; -import org.apache.ignite.IgniteException; -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.VisorOneNodeTask; - -/** - * Task that parse hadoop profiler logs. - */ -/** - * Task that parse hadoop profiler logs. - */ -@GridInternal -@Deprecated -public class VisorIgfsProfilerTask extends VisorOneNodeTask> { - /** */ - private static final long serialVersionUID = 0L; - - /** {@inheritDoc} */ - @Override protected VisorIgfsProfilerJob job(VisorIgfsProfilerTaskArg arg) { - return new VisorIgfsProfilerJob(arg, debug); - } - - /** - * Job that do actual profiler work. - */ - private static class VisorIgfsProfilerJob extends VisorJob> { - /** */ - private static final long serialVersionUID = 0L; - - /** - * Create job with given argument. - * - * @param arg IGFS name. - * @param debug Debug flag. - */ - private VisorIgfsProfilerJob(VisorIgfsProfilerTaskArg arg, boolean debug) { - super(arg, debug); - } - - /** {@inheritDoc} */ - @Override protected List run(VisorIgfsProfilerTaskArg arg) { - throw new IgniteException("IGFS operations are not supported in current version of Ignite"); - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorIgfsProfilerJob.class, this); - } - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/igfs/VisorIgfsProfilerTaskArg.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/igfs/VisorIgfsProfilerTaskArg.java deleted file mode 100644 index dcb60bb348549..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/igfs/VisorIgfsProfilerTaskArg.java +++ /dev/null @@ -1,73 +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.igfs; - -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; - -/** - * Argument for {@link VisorIgfsProfilerTask}. - */ -@Deprecated -public class VisorIgfsProfilerTaskArg extends VisorDataTransferObject { - /** */ - private static final long serialVersionUID = 0L; - - /** IGFS name. */ - private String igfsName; - - /** - * Default constructor. - */ - public VisorIgfsProfilerTaskArg() { - // No-op. - } - - /** - * @param igfsName IGFS name. - */ - public VisorIgfsProfilerTaskArg(String igfsName) { - this.igfsName = igfsName; - } - - /** - * @return IGFS name. - */ - public String getIgfsName() { - return igfsName; - } - - /** {@inheritDoc} */ - @Override protected void writeExternalData(ObjectOutput out) throws IOException { - U.writeString(out, igfsName); - } - - /** {@inheritDoc} */ - @Override protected void readExternalData(byte protoVer, ObjectInput in) throws IOException, ClassNotFoundException { - igfsName = U.readString(in); - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorIgfsProfilerTaskArg.class, this); - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/igfs/VisorIgfsProfilerUniformityCounters.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/igfs/VisorIgfsProfilerUniformityCounters.java deleted file mode 100644 index 9a4f4fabbbcba..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/igfs/VisorIgfsProfilerUniformityCounters.java +++ /dev/null @@ -1,233 +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.igfs; - -import java.io.IOException; -import java.io.ObjectInput; -import java.io.ObjectOutput; -import java.util.ArrayList; -import org.apache.ignite.internal.util.typedef.F; -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 static org.apache.ignite.internal.visor.igfs.VisorIgfsProfiler.UNIFORMITY_BLOCKS; -import static org.apache.ignite.internal.visor.igfs.VisorIgfsProfiler.UNIFORMITY_DFLT_BLOCK_SIZE; - -/** - * Class to support uniformity calculation. - *

- * Uniformity calculated as coefficient of variation. - *

- * Count read frequency for each file and compare with ideal uniform distribution. - */ -@Deprecated -public class VisorIgfsProfilerUniformityCounters extends VisorDataTransferObject { - /** */ - private static final long serialVersionUID = 0L; - - /** Analyzed file size in bytes. */ - private long fileSize; - - /** Current block size to calculate uniformity. */ - private long blockSize = UNIFORMITY_DFLT_BLOCK_SIZE; - - /** Collection of calculated counters. */ - private ArrayList counters = new ArrayList<>(); - - /** - * Default constructor. - */ - public VisorIgfsProfilerUniformityCounters() { - // No-op. - } - - /** - * Calculate block size. - * - * @param fileSize File size in bytes. - * @return Block size. - */ - private long calcBlockSize(long fileSize) { - return Math.max(UNIFORMITY_DFLT_BLOCK_SIZE, fileSize / UNIFORMITY_BLOCKS); - } - - /** - * Check if counters and blockSize should be adjusted according to file size. - * - * @param newFileSize New size of file. - */ - public void invalidate(long newFileSize) { - if (newFileSize < fileSize) { // If newFileSize is less than current fileSize then clear counters. - fileSize = newFileSize; - - counters.clear(); - - blockSize = calcBlockSize(fileSize); - } - else if (newFileSize > fileSize) // If newFileSize is bigger then current fileSize then adjust counters and blockSize. - compact(newFileSize); - } - - /** - * Perform compacting counters if {@code newBlockSize} is great more than twice then compact previous counters. - * - * @param newFileSize New file size to check. - */ - private void compact(long newFileSize) { - long newBlockSize = calcBlockSize(newFileSize); - - if (counters.isEmpty()) - blockSize = newBlockSize; - else { - if (newBlockSize >= 2 * blockSize) { - int ratio = (int)(newBlockSize / blockSize); - - ArrayList compacted = new ArrayList<>(); - - int sum = 0; - int cnt = 0; - - for (Integer counter : counters) { - sum += counter; - cnt++; - - if (cnt >= ratio) { - compacted.add(sum); - - sum = 0; - cnt = 0; - } - } - - if (sum > 0) - compacted.add(sum); - - counters.clear(); - counters.addAll(compacted); - - blockSize = newBlockSize; - } - } - - fileSize = newFileSize; - } - - /** - * Ensure counters capacity and initial state. - * - * @param minCap Desired minimum capacity. - */ - private void capacity(int minCap) { - counters.ensureCapacity(minCap); - - while (counters.size() < minCap) - counters.add(0); - } - - /** - * Increment counters by given pos and length. - * - * @param pos Position in file. - * @param len Read data length. - */ - public void increment(long pos, long len) { - int blockFrom = (int)(pos / blockSize); - int blockTo = (int)((pos + len) / blockSize) + 1; - - capacity(blockTo); - - for (int i = blockFrom; i < blockTo; i++) - counters.set(i, counters.get(i) + 1); - } - - /** - * Add given counters. - * - * @param other Counters to add. - */ - public void aggregate(VisorIgfsProfilerUniformityCounters other) { - if (fileSize < other.fileSize) - compact(other.fileSize); - else if (fileSize > other.fileSize) - other.compact(fileSize); - - int cnt = other.counters.size(); - - if (counters.size() < cnt) - capacity(cnt); - - for (int i = 0; i < cnt; i++) - counters.set(i, counters.get(i) + other.counters.get(i)); - } - - /** - * Calculate uniformity as standard deviation. See: http://en.wikipedia.org/wiki/Standard_deviation. - * - * @return Uniformity value as number in {@code 0..1} range. - */ - public double calc() { - if (counters.isEmpty()) - return -1; - else { - int cap = (int)(fileSize / blockSize + (fileSize % blockSize > 0 ? 1 : 0)); - - capacity(cap); - - int sz = counters.size(); - - int n = F.sumInt(counters); - - double mean = 1.0 / sz; - - // Calc standard deviation for block read frequency: SQRT(SUM(Freq_i - Mean)^2 / K) - // where Mean = 1 / K - // K - Number of blocks - // Freq_i = Counter_i / N - // N - Sum of all counters - double sigma = 0; - - for (Integer counter : counters) - sigma += Math.pow(counter.doubleValue() / n - mean, 2); - - sigma = Math.sqrt(sigma / sz); - - // Calc uniformity coefficient. - return 1.0 - sigma; - } - } - - /** {@inheritDoc} */ - @Override protected void writeExternalData(ObjectOutput out) throws IOException { - out.writeLong(fileSize); - out.writeLong(blockSize); - U.writeCollection(out, counters); - } - - /** {@inheritDoc} */ - @Override protected void readExternalData(byte protoVer, ObjectInput in) throws IOException, ClassNotFoundException { - fileSize = in.readLong(); - blockSize = in.readLong(); - counters = (ArrayList)U.readIntList(in); - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorIgfsProfilerUniformityCounters.class, this); - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/igfs/VisorIgfsResetMetricsTask.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/igfs/VisorIgfsResetMetricsTask.java deleted file mode 100644 index 54eb994eb6d87..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/igfs/VisorIgfsResetMetricsTask.java +++ /dev/null @@ -1,67 +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.igfs; - -import org.apache.ignite.IgniteException; -import org.apache.ignite.internal.processors.task.GridInternal; -import org.apache.ignite.internal.processors.task.GridVisorManagementTask; -import org.apache.ignite.internal.util.typedef.internal.S; -import org.apache.ignite.internal.visor.VisorJob; -import org.apache.ignite.internal.visor.VisorOneNodeTask; - -/** - * Resets IGFS metrics. - */ -@GridInternal -@GridVisorManagementTask -@Deprecated -public class VisorIgfsResetMetricsTask extends VisorOneNodeTask { - /** */ - private static final long serialVersionUID = 0L; - - /** {@inheritDoc} */ - @Override protected VisorIgfsResetMetricsJob job(VisorIgfsResetMetricsTaskArg arg) { - return new VisorIgfsResetMetricsJob(arg, debug); - } - - /** - * Job that reset IGFS metrics. - */ - private static class VisorIgfsResetMetricsJob extends VisorJob { - /** */ - private static final long serialVersionUID = 0L; - - /** - * @param arg IGFS names. - * @param debug Debug flag. - */ - private VisorIgfsResetMetricsJob(VisorIgfsResetMetricsTaskArg arg, boolean debug) { - super(arg, debug); - } - - /** {@inheritDoc} */ - @Override protected Void run(VisorIgfsResetMetricsTaskArg arg) { - throw new IgniteException("IGFS operations are not supported in current version of Ignite"); - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorIgfsResetMetricsJob.class, this); - } - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/igfs/VisorIgfsResetMetricsTaskArg.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/igfs/VisorIgfsResetMetricsTaskArg.java deleted file mode 100644 index 8631d8ef65dca..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/igfs/VisorIgfsResetMetricsTaskArg.java +++ /dev/null @@ -1,74 +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.igfs; - -import java.io.IOException; -import java.io.ObjectInput; -import java.io.ObjectOutput; -import java.util.Set; -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; - -/** - * Argument for {@link VisorIgfsResetMetricsTask}. - */ -@Deprecated -public class VisorIgfsResetMetricsTaskArg extends VisorDataTransferObject { - /** */ - private static final long serialVersionUID = 0L; - - /** IGFS names. */ - private Set igfsNames; - - /** - * Default constructor. - */ - public VisorIgfsResetMetricsTaskArg() { - // No-op. - } - - /** - * @param igfsNames IGFS names. - */ - public VisorIgfsResetMetricsTaskArg(Set igfsNames) { - this.igfsNames = igfsNames; - } - - /** - * @return IGFS names. - */ - public Set getIgfsNames() { - return igfsNames; - } - - /** {@inheritDoc} */ - @Override protected void writeExternalData(ObjectOutput out) throws IOException { - U.writeCollection(out, igfsNames); - } - - /** {@inheritDoc} */ - @Override protected void readExternalData(byte protoVer, ObjectInput in) throws IOException, ClassNotFoundException { - igfsNames = U.readSet(in); - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorIgfsResetMetricsTaskArg.class, this); - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/igfs/VisorIgfsSamplingStateTask.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/igfs/VisorIgfsSamplingStateTask.java deleted file mode 100644 index dbbceb2a9ef2d..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/igfs/VisorIgfsSamplingStateTask.java +++ /dev/null @@ -1,67 +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.igfs; - -import org.apache.ignite.IgniteException; -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.VisorOneNodeTask; - -/** - * Task to set IGFS instance sampling state. - */ -@GridInternal -@Deprecated -public class VisorIgfsSamplingStateTask extends VisorOneNodeTask { - /** */ - private static final long serialVersionUID = 0L; - - /** - * Job that perform parsing of IGFS profiler logs. - */ - private static class VisorIgfsSamplingStateJob extends VisorJob { - /** */ - private static final long serialVersionUID = 0L; - - /** - * Create job with given argument. - * - * @param arg Job argument. - * @param debug Debug flag. - */ - private VisorIgfsSamplingStateJob(VisorIgfsSamplingStateTaskArg arg, boolean debug) { - super(arg, debug); - } - - /** {@inheritDoc} */ - @Override protected Void run(VisorIgfsSamplingStateTaskArg arg) { - throw new IgniteException("IGFS operations are not supported in current version of Ignite"); - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorIgfsSamplingStateJob.class, this); - } - } - - /** {@inheritDoc} */ - @Override protected VisorIgfsSamplingStateJob job(VisorIgfsSamplingStateTaskArg arg) { - return new VisorIgfsSamplingStateJob(arg, debug); - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/igfs/VisorIgfsSamplingStateTaskArg.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/igfs/VisorIgfsSamplingStateTaskArg.java deleted file mode 100644 index 85fcdb6dc5853..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/igfs/VisorIgfsSamplingStateTaskArg.java +++ /dev/null @@ -1,87 +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.igfs; - -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; - -/** - * Argument for task returns changing of sampling state result. - */ -@Deprecated -public class VisorIgfsSamplingStateTaskArg extends VisorDataTransferObject { - /** */ - private static final long serialVersionUID = 0L; - - /** IGFS name. */ - private String name; - - /** {@code True} to turn on sampling, {@code false} to turn it off, {@code null} to clear sampling state. */ - private boolean enabled; - - /** - * Default constructor. - */ - public VisorIgfsSamplingStateTaskArg() { - // No-op. - } - - /** - * @param name IGFS name. - * @param enabled {@code True} to turn on sampling, {@code false} to turn it off, {@code null} to clear sampling state. - */ - public VisorIgfsSamplingStateTaskArg(String name, boolean enabled) { - this.name = name; - this.enabled = enabled; - } - - /** - * @return IGFS name. - */ - public String getName() { - return name; - } - - /** - * @return {@code True} to turn on sampling, {@code false} to turn it off, {@code null} to clear sampling state. - */ - public boolean isEnabled() { - return enabled; - } - - /** {@inheritDoc} */ - @Override protected void writeExternalData(ObjectOutput out) throws IOException { - U.writeString(out, name); - out.writeBoolean(enabled); - } - - /** {@inheritDoc} */ - @Override protected void readExternalData(byte protoVer, ObjectInput in) throws IOException, ClassNotFoundException { - name = U.readString(in); - enabled = in.readBoolean(); - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorIgfsSamplingStateTaskArg.class, this); - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/log/VisorLogFile.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/log/VisorLogFile.java deleted file mode 100644 index 2c2ac21eaf81d..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/log/VisorLogFile.java +++ /dev/null @@ -1,112 +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.log; - -import java.io.File; -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; - -/** - * Visor log file. - */ -public class VisorLogFile extends VisorDataTransferObject { - /** */ - private static final long serialVersionUID = 0L; - - /** File path. */ - private String path; - - /** File size. */ - private long size; - - /** File last modified timestamp. */ - private long lastModified; - - /** - * Default constructor. - */ - public VisorLogFile() { - // No-op. - } - - /** - * Create log file for given file. - * - * @param file Log file. - */ - public VisorLogFile(File file) { - this(file.getAbsolutePath(), file.length(), file.lastModified()); - } - - /** - * Create log file with given parameters. - * - * @param path File path. - * @param size File size. - * @param lastModified File last modified date. - */ - public VisorLogFile(String path, long size, long lastModified) { - this.path = path; - this.size = size; - this.lastModified = lastModified; - } - - /** - * @return File path. - */ - public String getPath() { - return path; - } - - /** - * @return File size. - */ - public long getSize() { - return size; - } - - /** - * @return File last modified timestamp. - */ - public long getLastModified() { - return lastModified; - } - - /** {@inheritDoc} */ - @Override protected void writeExternalData(ObjectOutput out) throws IOException { - U.writeString(out, path); - out.writeLong(size); - out.writeLong(lastModified); - } - - /** {@inheritDoc} */ - @Override protected void readExternalData(byte protoVer, ObjectInput in) throws IOException, ClassNotFoundException { - path = U.readString(in); - size = in.readLong(); - lastModified = in.readLong(); - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorLogFile.class, this); - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/log/VisorLogSearchResult.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/log/VisorLogSearchResult.java deleted file mode 100644 index 4eee4580eb47f..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/log/VisorLogSearchResult.java +++ /dev/null @@ -1,192 +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.log; - -import java.io.IOException; -import java.io.ObjectInput; -import java.io.ObjectOutput; -import java.util.Arrays; -import java.util.List; -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.VisorDataTransferObject; - -/** - * Result for log search operation. - * Contains found line and several lines before and after, plus other info. - */ -public class VisorLogSearchResult extends VisorDataTransferObject { - /** */ - private static final long serialVersionUID = 0L; - - /** Node ID. */ - private UUID nid; - - /** File path relative to the search folder. */ - private String filePath; - - /** File size. */ - private long fileSize; - - /** Timestamp of last modification of the file. */ - private long lastModified; - - /** Lines of text including found line and several lines before and after. */ - private List lines; - - /** Line number in the file, 1 based. */ - private int lineNum; - - /** Lines count in the file. */ - private int lineCnt; - - /** File content encoding. */ - private String encoding; - - /** - * Default constructor. - */ - public VisorLogSearchResult() { - // No-op. - } - - /** - * Create log search result with given parameters. - * - * @param nid Node ID. - * @param filePath File path relative to the search folder. - * @param fileSize File size. - * @param lastModified Timestamp of last modification of the file. - * @param lines Lines of text including found line and several lines before and after. - * @param lineNum Line number in the file, 1 based. - * @param lineCnt Lines count in the file. - * @param encoding File content encoding. - */ - public VisorLogSearchResult( - UUID nid, - String filePath, - long fileSize, - long lastModified, - String[] lines, - int lineNum, - int lineCnt, - String encoding - ) { - this.nid = nid; - this.filePath = filePath; - this.fileSize = fileSize; - this.lastModified = lastModified; - this.lines = Arrays.asList(lines); - this.lineNum = lineNum; - this.lineCnt = lineCnt; - this.encoding = encoding; - } - - /** - * @return Node ID. - */ - public UUID getNid() { - return nid; - } - - /** - * @return File path relative to the search folder. - */ - public String getFilePath() { - return filePath; - } - - /** - * @return File size. - */ - public long getFileSize() { - return fileSize; - } - - /** - * @return Timestamp of last modification of the file. - */ - public long getLastModified() { - return lastModified; - } - - /** - * @return Lines of text including found line and several lines before and after. - */ - public List getLines() { - return lines; - } - - /** - * @return Line number in the file, 1 based. - */ - public int getLineNumber() { - return lineNum; - } - - /** - * @return Lines count in the file. - */ - public int getLineCount() { - return lineCnt; - } - - /** - * @return File content encoding. - */ - public String getEncoding() { - return encoding; - } - - /** - * @return Found line. - */ - public String getLine() { - return lines.get(lines.size() / 2); - } - - /** {@inheritDoc} */ - @Override protected void writeExternalData(ObjectOutput out) throws IOException { - U.writeUuid(out, nid); - U.writeString(out, filePath); - out.writeLong(fileSize); - out.writeLong(lastModified); - U.writeCollection(out, lines); - out.writeInt(lineNum); - out.writeInt(lineCnt); - U.writeString(out, encoding); - } - - /** {@inheritDoc} */ - @Override protected void readExternalData(byte protoVer, ObjectInput in) throws IOException, ClassNotFoundException { - nid = U.readUuid(in); - filePath = U.readString(in); - fileSize = in.readLong(); - lastModified = in.readLong(); - lines = U.readList(in); - lineNum = in.readInt(); - lineCnt = in.readInt(); - encoding = U.readString(in); - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorLogSearchResult.class, this); - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/log/VisorLogSearchTask.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/log/VisorLogSearchTask.java deleted file mode 100644 index 04ee29cda70bc..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/log/VisorLogSearchTask.java +++ /dev/null @@ -1,239 +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.log; - -import java.io.File; -import java.io.IOException; -import java.nio.charset.Charset; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Deque; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.UUID; -import org.apache.ignite.IgniteException; -import org.apache.ignite.compute.ComputeJobResult; -import org.apache.ignite.internal.processors.task.GridInternal; -import org.apache.ignite.internal.processors.task.GridVisorManagementTask; -import org.apache.ignite.internal.util.io.GridReversedLinesFileReader; -import org.apache.ignite.internal.util.lang.GridTuple3; -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.VisorMultiNodeTask; -import org.jetbrains.annotations.Nullable; - -import static org.apache.ignite.internal.visor.util.VisorTaskUtils.decode; -import static org.apache.ignite.internal.visor.util.VisorTaskUtils.matchedFiles; -import static org.apache.ignite.internal.visor.util.VisorTaskUtils.resolveIgnitePath; -import static org.apache.ignite.internal.visor.util.VisorTaskUtils.resolveSymbolicLink; -import static org.apache.ignite.internal.visor.util.VisorTaskUtils.textFile; - -/** - * Search text matching in logs - */ -@GridInternal -@GridVisorManagementTask -public class VisorLogSearchTask extends VisorMultiNodeTask> { - /** */ - private static final long serialVersionUID = 0L; - - /** How many lines to read around line with found text. */ - public static final int LINE_CNT = 21; - - /** How many lines should be read before and after line with found text. */ - public static final int HALF = LINE_CNT / 2; - - /** {@inheritDoc} */ - @Override protected VisorLogSearchJob job(VisorLogSearchTaskArg arg) { - return new VisorLogSearchJob(arg, debug); - } - - /** {@inheritDoc} */ - @Nullable @Override protected VisorLogSearchTaskResult reduce0(List results) { - List searchRes = new ArrayList<>(); - Map exRes = U.newHashMap(0); - - // Separate successfully executed results and exceptions. - for (ComputeJobResult result : results) { - if (result.getException() != null) - exRes.put(result.getException(), result.getNode().id()); - else if (result.getData() != null) { - Collection data = result.getData(); - - searchRes.addAll(data); - } - } - - return new VisorLogSearchTaskResult(exRes.isEmpty() ? null : exRes, searchRes.isEmpty() ? null : searchRes); - } - - /** - * Job to perform search on node. - */ - private static class VisorLogSearchJob extends VisorJob> { - /** */ - private static final long serialVersionUID = 0L; - - /** - * @param arg Search descriptor. - * @param debug Debug flag. - */ - private VisorLogSearchJob(VisorLogSearchTaskArg arg, boolean debug) { - super(arg, debug); - } - - /** - * @param f File to read. - * @param charset Text charset. - * @param searchStr Search string. - * @param limit Max number of search results. - * @return Collection of found descriptors. - * @throws IOException In case of I/O error. - */ - private List> searchInFile(File f, Charset charset, String searchStr, - int limit) throws IOException { - List> searched = new ArrayList<>(); - - int line = 0; - - try (GridReversedLinesFileReader reader = new GridReversedLinesFileReader(f, 4096, charset)) { - Deque lastLines = new LinkedList<>(); - - String s; - int lastFoundLine = 0, foundCnt = 0; - - while ((s = reader.readLine()) != null) { - line++; - - if (lastFoundLine > 0 && line - lastFoundLine <= HALF) { - for (int i = searched.size() - 1; i >= 0; i--) { - GridTuple3 tup = searched.get(i); - - int delta = line - tup.get2(); - - if (delta <= HALF && delta != 0) - tup.get1()[HALF - delta] = s; - else - break; - } - } - - if (foundCnt < limit) { - if (s.toLowerCase().contains(searchStr)) { - String[] buf = new String[LINE_CNT]; - - buf[HALF] = s; - - int i = 1; - - for (String l : lastLines) { - buf[HALF + i] = l; - - i++; - } - - lastFoundLine = line; - - searched.add(new GridTuple3<>(buf, line, 0)); - - foundCnt++; - } - } - - if (lastLines.size() >= HALF) - lastLines.removeFirst(); - - lastLines.add(s); - } - } - - for (GridTuple3 entry : searched) { - entry.set2(line - entry.get2() + 1); - entry.set3(line); - } - - return searched; - } - - /** {@inheritDoc} */ - @Override protected Collection run(VisorLogSearchTaskArg arg) { - try { - File folder = resolveIgnitePath(arg.getFolder()); - - if (folder == null) - return null; - - folder = resolveSymbolicLink(folder); - - UUID uuid = ignite.localNode().id(); - String nid = uuid.toString().toLowerCase(); - - String filePtrn = arg.getFilePattern().replace("@nid8", nid.substring(0, 8)).replace("@nid", nid); - - int pathIdx = (folder.isDirectory() ? folder : folder.getParentFile()).getAbsolutePath().length() + 1; - - List matchingFiles = matchedFiles(folder, filePtrn); - - Collection results = new ArrayList<>(arg.getLimit()); - - int resCnt = 0; - - for (VisorLogFile logFile : matchingFiles) { - try { - File f = new File(logFile.getPath()); - - if (textFile(f, false)) { - Charset charset = decode(f); - - if (resCnt == arg.getLimit()) - break; - - List> searched = - searchInFile(f, charset, arg.getSearchString(), arg.getLimit() - resCnt); - - resCnt += searched.size(); - - String path = f.getAbsolutePath().substring(pathIdx); - long sz = f.length(), lastModified = f.lastModified(); - - for (GridTuple3 e : searched) { - results.add(new VisorLogSearchResult(uuid, path, sz, lastModified, - e.get1(), e.get2(), e.get3(), charset.name())); - } - } - } - catch (IOException ignored) { - } - } - - return results.isEmpty() ? null : results; - } - catch (Exception e) { - throw new IgniteException(e); - } - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorLogSearchJob.class, this); - } - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/log/VisorLogSearchTaskArg.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/log/VisorLogSearchTaskArg.java deleted file mode 100644 index aa0597001056c..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/log/VisorLogSearchTaskArg.java +++ /dev/null @@ -1,114 +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.log; - -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; - -/** - * Arguments for {@link VisorLogSearchTask}. - */ -public class VisorLogSearchTaskArg extends VisorDataTransferObject { - /** */ - private static final long serialVersionUID = 0L; - - /** Searched string. */ - private String searchStr; - - /** Folder. */ - private String folder; - - /** File name search pattern. */ - private String filePtrn; - - /** Max number of results. */ - private int limit; - - /** - * Default constructor. - */ - public VisorLogSearchTaskArg() { - // No-op. - } - - /** - * @param searchStr Searched string. - * @param folder Folder. - * @param filePtrn File name search pattern. - * @param limit Max number of results. - */ - public VisorLogSearchTaskArg(String searchStr, String folder, String filePtrn, int limit) { - this.searchStr = searchStr; - this.folder = folder; - this.filePtrn = filePtrn; - this.limit = limit; - } - - /** - * @return Searched string. - */ - public String getSearchString() { - return searchStr; - } - - /** - * @return Folder. - */ - public String getFolder() { - return folder; - } - - /** - * @return File name search pattern. - */ - public String getFilePattern() { - return filePtrn; - } - - /** - * @return Max number of results. - */ - public int getLimit() { - return limit; - } - - /** {@inheritDoc} */ - @Override protected void writeExternalData(ObjectOutput out) throws IOException { - U.writeString(out, searchStr); - U.writeString(out, folder); - U.writeString(out, filePtrn); - out.writeInt(limit); - } - - /** {@inheritDoc} */ - @Override protected void readExternalData(byte protoVer, ObjectInput in) throws IOException, ClassNotFoundException { - searchStr = U.readString(in); - folder = U.readString(in); - filePtrn = U.readString(in); - limit = in.readInt(); - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorLogSearchTaskArg.class, this); - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/log/VisorLogSearchTaskResult.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/log/VisorLogSearchTaskResult.java deleted file mode 100644 index 3104c3ab3edd9..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/log/VisorLogSearchTaskResult.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.log; - -import java.io.IOException; -import java.io.ObjectInput; -import java.io.ObjectOutput; -import java.util.List; -import java.util.Map; -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.VisorDataTransferObject; - -/** - * Result for log search operation. - * Contains found line and several lines before and after, plus other info. - */ -public class VisorLogSearchTaskResult extends VisorDataTransferObject { - /** */ - private static final long serialVersionUID = 0L; - - /** List of exceptions by node ID. */ - private Map exceptions; - - /** List of log search results. */ - private List results; - - /** - * Default constructor. - */ - public VisorLogSearchTaskResult() { - // No-op. - } - - /** - * Create log search result with given parameters. - * - * @param exceptions List of exceptions by node ID. - * @param results List of log search results. - */ - public VisorLogSearchTaskResult(Map exceptions, List results) { - this.exceptions = exceptions; - this.results = results; - } - - /** - * @return List of exceptions by node ID. - */ - public Map getExceptions() { - return exceptions; - } - - /** - * @return List of log search results. - */ - public List getResults() { - return results; - } - - /** {@inheritDoc} */ - @Override protected void writeExternalData(ObjectOutput out) throws IOException { - U.writeMap(out, exceptions); - U.writeCollection(out, results); - } - - /** {@inheritDoc} */ - @Override protected void readExternalData(byte protoVer, ObjectInput in) throws IOException, ClassNotFoundException { - exceptions = U.readMap(in); - results = U.readList(in); - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorLogSearchTaskResult.class, this); - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/misc/VisorAckTask.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/misc/VisorAckTask.java deleted file mode 100644 index eaa036cb2ae21..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/misc/VisorAckTask.java +++ /dev/null @@ -1,75 +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.misc; - -import java.util.List; -import org.apache.ignite.compute.ComputeJobResult; -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.jetbrains.annotations.Nullable; - -/** - * Ack task to run on node. - */ -@GridInternal -public class VisorAckTask extends VisorMultiNodeTask { - /** */ - private static final long serialVersionUID = 0L; - - /** {@inheritDoc} */ - @Override protected VisorAckJob job(VisorAckTaskArg arg) { - return new VisorAckJob(arg, debug); - } - - /** {@inheritDoc} */ - @Nullable @Override protected Void reduce0(List results) { - return null; - } - - /** - * Ack job to run on node. - */ - private static class VisorAckJob extends VisorJob { - /** */ - private static final long serialVersionUID = 0L; - - /** - * Create job with given argument. - * - * @param arg Message to ack in node console. - * @param debug Debug flag. - */ - private VisorAckJob(VisorAckTaskArg arg, boolean debug) { - super(arg, debug); - } - - /** {@inheritDoc} */ - @Override protected Void run(VisorAckTaskArg arg) { - System.out.println(": ack: " + (arg.getMessage() == null ? ignite.localNode().id() : arg.getMessage())); - - return null; - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorAckJob.class, this); - } - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/misc/VisorAckTaskArg.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/misc/VisorAckTaskArg.java deleted file mode 100644 index 93c4aef71a2d2..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/misc/VisorAckTaskArg.java +++ /dev/null @@ -1,72 +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.misc; - -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; - -/** - * Arguments for {@link VisorAckTask}. - */ -public class VisorAckTaskArg extends VisorDataTransferObject { - /** */ - private static final long serialVersionUID = 0L; - - /** Message to show. */ - private String msg; - - /** - * Default constructor. - */ - public VisorAckTaskArg() { - // No-op. - } - - /** - * @param msg Message to show. - */ - public VisorAckTaskArg(String msg) { - this.msg = msg; - } - - /** - * @return Cache name. - */ - public String getMessage() { - return msg; - } - - /** {@inheritDoc} */ - @Override protected void writeExternalData(ObjectOutput out) throws IOException { - U.writeString(out, msg); - } - - /** {@inheritDoc} */ - @Override protected void readExternalData(byte protoVer, ObjectInput in) throws IOException, ClassNotFoundException { - msg = U.readString(in); - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorAckTaskArg.class, this); - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/misc/VisorChangeGridActiveStateTask.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/misc/VisorChangeGridActiveStateTask.java deleted file mode 100644 index 86aee0343202b..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/misc/VisorChangeGridActiveStateTask.java +++ /dev/null @@ -1,67 +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.misc; - -import org.apache.ignite.internal.processors.task.GridInternal; -import org.apache.ignite.internal.processors.task.GridVisorManagementTask; -import org.apache.ignite.internal.util.typedef.internal.S; -import org.apache.ignite.internal.visor.VisorJob; -import org.apache.ignite.internal.visor.VisorOneNodeTask; - -/** - * Task for changing grid active state. - */ -@GridInternal -@GridVisorManagementTask -public class VisorChangeGridActiveStateTask extends VisorOneNodeTask { - /** */ - private static final long serialVersionUID = 0L; - - /** {@inheritDoc} */ - @Override protected VisorChangeGridActiveStateJob job(VisorChangeGridActiveStateTaskArg arg) { - return new VisorChangeGridActiveStateJob(arg, debug); - } - - /** - * Job for changing grid active state. - */ - private static class VisorChangeGridActiveStateJob extends VisorJob { - /** */ - private static final long serialVersionUID = 0L; - - /** - * @param arg New state of grid. - * @param debug Debug flag. - */ - private VisorChangeGridActiveStateJob(VisorChangeGridActiveStateTaskArg arg, boolean debug) { - super(arg, debug); - } - - /** {@inheritDoc} */ - @Override protected Void run(VisorChangeGridActiveStateTaskArg arg) { - ignite.active(arg.isActive()); - - return null; - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorChangeGridActiveStateJob.class, this); - } - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/misc/VisorChangeGridActiveStateTaskArg.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/misc/VisorChangeGridActiveStateTaskArg.java deleted file mode 100644 index 15e76fb98cc9c..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/misc/VisorChangeGridActiveStateTaskArg.java +++ /dev/null @@ -1,71 +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.misc; - -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.visor.VisorDataTransferObject; - -/** - * Argument for {@link VisorChangeGridActiveStateTask}. - */ -public class VisorChangeGridActiveStateTaskArg extends VisorDataTransferObject { - /** */ - private static final long serialVersionUID = 0L; - - /** If True start activation process. If False start deactivation process. */ - private boolean active; - - /** - * Default constructor. - */ - public VisorChangeGridActiveStateTaskArg() { - // No-op. - } - - /** - * @param active If True start activation process. If False start deactivation process. - */ - public VisorChangeGridActiveStateTaskArg(boolean active) { - this.active = active; - } - - /** - * @return If True start activation process. If False start deactivation process. - */ - public boolean isActive() { - return active; - } - - /** {@inheritDoc} */ - @Override protected void writeExternalData(ObjectOutput out) throws IOException { - out.writeBoolean(active); - } - - /** {@inheritDoc} */ - @Override protected void readExternalData(byte protoVer, ObjectInput in) throws IOException, ClassNotFoundException { - active = in.readBoolean(); - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorChangeGridActiveStateTaskArg.class, this); - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/misc/VisorLatestVersionTask.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/misc/VisorLatestVersionTask.java deleted file mode 100644 index 8c250996f974f..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/misc/VisorLatestVersionTask.java +++ /dev/null @@ -1,63 +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.misc; - -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.VisorOneNodeTask; - -/** - * Task for collecting latest version. - */ -@GridInternal -public class VisorLatestVersionTask extends VisorOneNodeTask { - /** */ - private static final long serialVersionUID = 0L; - - /** {@inheritDoc} */ - @Override protected VisorLatestVersionJob job(Void arg) { - return new VisorLatestVersionJob(arg, debug); - } - - /** - * Job for collecting latest version. - */ - private static class VisorLatestVersionJob extends VisorJob { - /** */ - private static final long serialVersionUID = 0L; - - /** - * @param arg Formal job argument. - * @param debug Debug flag. - */ - private VisorLatestVersionJob(Void arg, boolean debug) { - super(arg, debug); - } - - /** {@inheritDoc} */ - @Override protected String run(Void arg) { - return ignite.latestVersion(); - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorLatestVersionJob.class, this); - } - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/misc/VisorNopTask.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/misc/VisorNopTask.java deleted file mode 100644 index aeca762a0f1a9..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/misc/VisorNopTask.java +++ /dev/null @@ -1,98 +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.misc; - -import java.util.List; -import java.util.Map; -import java.util.Random; -import org.apache.ignite.cluster.ClusterNode; -import org.apache.ignite.compute.ComputeJob; -import org.apache.ignite.compute.ComputeJobAdapter; -import org.apache.ignite.compute.ComputeJobResult; -import org.apache.ignite.compute.ComputeJobResultPolicy; -import org.apache.ignite.compute.ComputeTask; -import org.apache.ignite.internal.util.GridLeanMap; -import org.apache.ignite.internal.util.typedef.internal.S; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -/** - * Nop task with random timeout. - */ -public class VisorNopTask implements ComputeTask { - /** */ - private static final long serialVersionUID = 0L; - - /** {@inheritDoc} */ - @NotNull @Override public Map map(List subgrid, - @Nullable Integer arg) { - - Map map = new GridLeanMap<>(subgrid.size()); - - for (ClusterNode node : subgrid) - map.put(new VisorNopJob(arg), node); - - return map; - } - - /** {@inheritDoc} */ - @Override public ComputeJobResultPolicy result(ComputeJobResult res, - List rcvd) { - return ComputeJobResultPolicy.WAIT; - } - - /** {@inheritDoc} */ - @Nullable @Override public Void reduce(List results) { - return null; - } - - /** - * Nop job with random timeout. - */ - private static class VisorNopJob extends ComputeJobAdapter { - /** */ - private static final long serialVersionUID = 0L; - - /** - * @param arg Job argument. - */ - private VisorNopJob(@Nullable Object arg) { - super(arg); - } - - /** {@inheritDoc} */ - @SuppressWarnings("ConstantConditions") - @Nullable @Override public Object execute() { - try { - Integer maxTimeout = argument(0); - - Thread.sleep(new Random().nextInt(maxTimeout)); - } - catch (InterruptedException ignored) { - Thread.currentThread().interrupt(); - } - - return null; - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorNopJob.class, this); - } - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/misc/VisorResolveHostNameTask.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/misc/VisorResolveHostNameTask.java deleted file mode 100644 index f851e262abe96..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/misc/VisorResolveHostNameTask.java +++ /dev/null @@ -1,107 +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.misc; - -import java.net.InetAddress; -import java.util.Collection; -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; -import org.apache.ignite.IgniteException; -import org.apache.ignite.internal.processors.task.GridInternal; -import org.apache.ignite.internal.util.IgniteUtils; -import org.apache.ignite.internal.util.typedef.internal.S; -import org.apache.ignite.internal.visor.VisorJob; -import org.apache.ignite.internal.visor.VisorOneNodeTask; -import org.apache.ignite.lang.IgniteBiTuple; - -/** - * Task that resolve host name for specified IP address from node. - */ -@GridInternal -public class VisorResolveHostNameTask extends VisorOneNodeTask> { - /** */ - private static final long serialVersionUID = 0L; - - /** {@inheritDoc} */ - @Override protected VisorResolveHostNameJob job(Void arg) { - return new VisorResolveHostNameJob(arg, debug); - } - - /** - * Job that resolve host name for specified IP address. - */ - private static class VisorResolveHostNameJob extends VisorJob> { - /** */ - private static final long serialVersionUID = 0L; - - /** - * Create job. - * - * @param arg List of IP address for resolve. - * @param debug Debug flag. - */ - private VisorResolveHostNameJob(Void arg, boolean debug) { - super(arg, debug); - } - - /** {@inheritDoc} */ - @Override protected Map run(Void arg) { - Map res = new HashMap<>(); - - try { - IgniteBiTuple, Collection> addrs = - IgniteUtils.resolveLocalAddresses(InetAddress.getByName("0.0.0.0"), true); - - assert (addrs.get1() != null); - assert (addrs.get2() != null); - - Iterator ipIt = addrs.get1().iterator(); - Iterator hostIt = addrs.get2().iterator(); - - while (ipIt.hasNext() && hostIt.hasNext()) { - String ip = ipIt.next(); - - String hostName = hostIt.next(); - - if (hostName == null || hostName.trim().isEmpty()) { - try { - if (InetAddress.getByName(ip).isLoopbackAddress()) - res.put(ip, "localhost"); - } - catch (Exception ignore) { - //no-op - } - } - else if (!hostName.equals(ip)) - res.put(ip, hostName); - } - } - catch (Exception e) { - throw new IgniteException("Failed to resolve host name", e); - } - - return res; - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorResolveHostNameJob.class, this); - } - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorAffinityTopologyVersion.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorAffinityTopologyVersion.java deleted file mode 100644 index 83b2fb1e3b58c..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorAffinityTopologyVersion.java +++ /dev/null @@ -1,87 +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.node; - -import java.io.IOException; -import java.io.ObjectInput; -import java.io.ObjectOutput; -import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion; -import org.apache.ignite.internal.util.typedef.internal.S; -import org.apache.ignite.internal.visor.VisorDataTransferObject; - -/** - * Data transfer object for {@link AffinityTopologyVersion} - */ -public class VisorAffinityTopologyVersion extends VisorDataTransferObject { - /** */ - private static final long serialVersionUID = 0L; - - /** */ - private long topVer; - - /** */ - private int minorTopVer; - - /** - * Default constructor. - */ - public VisorAffinityTopologyVersion() { - // No-op. - } - - /** - * Create data transfer object for affinity topology version. - * - * @param affTopVer Affinity topology version. - */ - public VisorAffinityTopologyVersion(AffinityTopologyVersion affTopVer) { - topVer = affTopVer.topologyVersion(); - minorTopVer = affTopVer.minorTopologyVersion(); - } - - /** - * @return Topology version. - */ - public long getTopologyVersion() { - return topVer; - } - - /** - * @return Minor topology version. - */ - public int getMinorTopologyVersion() { - return minorTopVer; - } - - /** {@inheritDoc} */ - @Override protected void writeExternalData(ObjectOutput out) throws IOException { - out.writeLong(topVer); - out.writeInt(minorTopVer); - } - - /** {@inheritDoc} */ - @Override protected void readExternalData(byte protoVer, ObjectInput in) throws IOException, ClassNotFoundException { - topVer = in.readLong(); - minorTopVer = in.readInt(); - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorAffinityTopologyVersion.class, this); - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorAtomicConfiguration.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorAtomicConfiguration.java deleted file mode 100644 index 2c77d6ef11cdb..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorAtomicConfiguration.java +++ /dev/null @@ -1,101 +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.node; - -import java.io.IOException; -import java.io.ObjectInput; -import java.io.ObjectOutput; -import org.apache.ignite.cache.CacheMode; -import org.apache.ignite.configuration.AtomicConfiguration; -import org.apache.ignite.internal.util.typedef.internal.S; -import org.apache.ignite.internal.visor.VisorDataTransferObject; - -/** - * Data transfer object for configuration of atomic data structures. - */ -public class VisorAtomicConfiguration extends VisorDataTransferObject { - /** */ - private static final long serialVersionUID = 0L; - - /** Atomic sequence reservation size. */ - private int seqReserveSize; - - /** Cache mode. */ - private CacheMode cacheMode; - - /** Number of backups. */ - private int backups; - - /** - * Default constructor. - */ - public VisorAtomicConfiguration() { - // No-op. - } - - /** - * Create data transfer object for atomic configuration. - * - * @param src Atomic configuration. - */ - public VisorAtomicConfiguration(AtomicConfiguration src) { - seqReserveSize = src.getAtomicSequenceReserveSize(); - cacheMode = src.getCacheMode(); - backups = src.getBackups(); - } - - /** - * @return Atomic sequence reservation size. - */ - public int getAtomicSequenceReserveSize() { - return seqReserveSize; - } - - /** - * @return Cache mode. - */ - public CacheMode getCacheMode() { - return cacheMode; - } - - /** - * @return Number of backup nodes. - */ - public int getBackups() { - return backups; - } - - /** {@inheritDoc} */ - @Override protected void writeExternalData(ObjectOutput out) throws IOException { - out.writeInt(seqReserveSize); - out.writeByte(CacheMode.toCode(cacheMode)); - out.writeInt(backups); - } - - /** {@inheritDoc} */ - @Override protected void readExternalData(byte protoVer, ObjectInput in) throws IOException, ClassNotFoundException { - seqReserveSize = in.readInt(); - cacheMode = CacheMode.fromCode(in.readByte()); - backups = in.readInt(); - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorAtomicConfiguration.class, this); - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorBasicConfiguration.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorBasicConfiguration.java deleted file mode 100644 index 72e4dce7e4ea4..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorBasicConfiguration.java +++ /dev/null @@ -1,549 +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.node; - -import java.io.IOException; -import java.io.ObjectInput; -import java.io.ObjectOutput; -import org.apache.ignite.configuration.DeploymentMode; -import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.internal.IgniteEx; -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 java.lang.System.getProperty; -import static org.apache.ignite.IgniteSystemProperties.IGNITE_HOME; -import static org.apache.ignite.IgniteSystemProperties.IGNITE_LOCAL_HOST; -import static org.apache.ignite.IgniteSystemProperties.IGNITE_NO_ASCII; -import static org.apache.ignite.IgniteSystemProperties.IGNITE_NO_DISCO_ORDER; -import static org.apache.ignite.IgniteSystemProperties.IGNITE_NO_SHUTDOWN_HOOK; -import static org.apache.ignite.IgniteSystemProperties.IGNITE_PROG_NAME; -import static org.apache.ignite.IgniteSystemProperties.IGNITE_QUIET; -import static org.apache.ignite.IgniteSystemProperties.IGNITE_SUCCESS_FILE; -import static org.apache.ignite.IgniteSystemProperties.IGNITE_UPDATE_NOTIFIER; -import static org.apache.ignite.internal.processors.cluster.ClusterProcessor.DFLT_UPDATE_NOTIFIER; -import static org.apache.ignite.internal.visor.util.VisorTaskUtils.boolValue; -import static org.apache.ignite.internal.visor.util.VisorTaskUtils.compactClass; - -/** - * Data transfer object for node basic configuration properties. - */ -public class VisorBasicConfiguration extends VisorDataTransferObject { - /** */ - private static final long serialVersionUID = 0L; - - /** Ignite instance name. */ - private String igniteInstanceName; - - /** IGNITE_HOME determined at startup. */ - private String ggHome; - - /** Local host value used. */ - private String locHost; - - /** Marshaller used. */ - private String marsh; - - /** Deployment Mode. */ - private DeploymentMode deployMode; - - /** Client mode flag. */ - private Boolean clientMode; - - /** Whether this node daemon or not. */ - private boolean daemon; - - /** Whether remote JMX is enabled. */ - private boolean jmxRemote; - - /** Is node restart enabled. */ - private boolean restart; - - /** Network timeout. */ - private long netTimeout; - - /** Logger used on node. */ - private String log; - - /** Discovery startup delay. */ - private long discoStartupDelay; - - /** MBean server name */ - private String mBeanSrv; - - /** Whether ASCII logo is disabled. */ - private boolean noAscii; - - /** Whether no discovery order is allowed. */ - private boolean noDiscoOrder; - - /** Whether shutdown hook is disabled. */ - private boolean noShutdownHook; - - /** Name of command line program. */ - private String progName; - - /** Whether node is in quiet mode. */ - private boolean quiet; - - /** Success file name. */ - private String successFile; - - /** Whether update checker is enabled. */ - private boolean updateNtf; - - /** Active on start flag. */ - private boolean activeOnStart; - - /** Address resolver. */ - private String addrRslvr; - - /** Flag indicating whether cache sanity check is enabled. */ - private boolean cacheSanityCheckEnabled; - - /** User's class loader. */ - private String clsLdr; - - /** Consistent globally unique node ID which survives node restarts. */ - private String consistentId; - - /** Failure detection timeout. */ - private Long failureDetectionTimeout; - - /** Ignite work folder. */ - private String igniteWorkDir; - - /** */ - private boolean lateAffAssignment; - - /** Marshal local jobs. */ - private boolean marshLocJobs; - - /** Full metrics enabled flag. */ - private long metricsUpdateFreq; - - /** Failure detection timeout for client nodes. */ - private Long clientFailureDetectionTimeout; - - /** Message send retries delay. */ - private int sndRetryCnt; - - /** Interval between message send retries. */ - private long sndRetryDelay; - - /** Base port number for time server. */ - private int timeSrvPortBase; - - /** Port number range for time server. */ - private int timeSrvPortRange; - - /** Utility cache pool keep alive time. */ - private long utilityCacheKeepAliveTime; - - /** - * Default constructor. - */ - public VisorBasicConfiguration() { - // No-op. - } - - /** - * Create data transfer object for node basic configuration properties. - * - * @param ignite Grid. - * @param c Grid configuration. - */ - public VisorBasicConfiguration(IgniteEx ignite, IgniteConfiguration c) { - igniteInstanceName = c.getIgniteInstanceName(); - ggHome = getProperty(IGNITE_HOME, c.getIgniteHome()); - locHost = getProperty(IGNITE_LOCAL_HOST, c.getLocalHost()); - marsh = compactClass(c.getMarshaller()); - deployMode = c.getDeploymentMode(); - clientMode = c.isClientMode(); - jmxRemote = ignite.isJmxRemoteEnabled(); - restart = ignite.isRestartEnabled(); - netTimeout = c.getNetworkTimeout(); - log = compactClass(c.getGridLogger()); - discoStartupDelay = c.getDiscoveryStartupDelay(); - mBeanSrv = compactClass(c.getMBeanServer()); - noAscii = boolValue(IGNITE_NO_ASCII, false); - noDiscoOrder = boolValue(IGNITE_NO_DISCO_ORDER, false); - noShutdownHook = boolValue(IGNITE_NO_SHUTDOWN_HOOK, false); - progName = getProperty(IGNITE_PROG_NAME); - quiet = boolValue(IGNITE_QUIET, true); - successFile = getProperty(IGNITE_SUCCESS_FILE); - updateNtf = boolValue(IGNITE_UPDATE_NOTIFIER, DFLT_UPDATE_NOTIFIER); - activeOnStart = c.isActiveOnStart(); - addrRslvr = compactClass(c.getAddressResolver()); - cacheSanityCheckEnabled = c.isCacheSanityCheckEnabled(); - clsLdr = compactClass(c.getClassLoader()); - consistentId = c.getConsistentId() != null ? String.valueOf(c.getConsistentId()) : null; - failureDetectionTimeout = c.getFailureDetectionTimeout(); - igniteWorkDir = c.getWorkDirectory(); - lateAffAssignment = c.isLateAffinityAssignment(); - marshLocJobs = c.isMarshalLocalJobs(); - metricsUpdateFreq = c.getMetricsUpdateFrequency(); - clientFailureDetectionTimeout = c.getClientFailureDetectionTimeout(); - sndRetryCnt = c.getNetworkSendRetryCount(); - sndRetryDelay = c.getNetworkSendRetryDelay(); - timeSrvPortBase = c.getTimeServerPortBase(); - timeSrvPortRange = c.getTimeServerPortRange(); - utilityCacheKeepAliveTime = c.getUtilityCacheKeepAliveTime(); - } - - /** - * @return Ignite instance name. - */ - @Nullable public String getIgniteInstanceName() { - return igniteInstanceName; - } - - /** - * @return IGNITE_HOME determined at startup. - */ - @Nullable public String getGgHome() { - return ggHome; - } - - /** - * @return Local host value used. - */ - @Nullable public String getLocalHost() { - return locHost; - } - - /** - * @return Marshaller used. - */ - public String getMarshaller() { - return marsh; - } - - /** - * @return Deployment Mode. - */ - public Object getDeploymentMode() { - return deployMode; - } - - /** - * @return Client mode flag. - */ - public Boolean isClientMode() { - return clientMode; - } - - /** - * @return Whether this node daemon or not. - */ - public boolean isDaemon() { - return daemon; - } - - /** - * @return Whether remote JMX is enabled. - */ - public boolean isJmxRemote() { - return jmxRemote; - } - - /** - * @return Is node restart enabled. - */ - public boolean isRestart() { - return restart; - } - - /** - * @return Network timeout. - */ - public long getNetworkTimeout() { - return netTimeout; - } - - /** - * @return Logger used on node. - */ - public String getLogger() { - return log; - } - - /** - * @return Discovery startup delay. - */ - public long getDiscoStartupDelay() { - return discoStartupDelay; - } - - /** - * @return MBean server name - */ - @Nullable public String getMBeanServer() { - return mBeanSrv; - } - - /** - * @return Whether ASCII logo is disabled. - */ - public boolean isNoAscii() { - return noAscii; - } - - /** - * @return Whether no discovery order is allowed. - */ - public boolean isNoDiscoOrder() { - return noDiscoOrder; - } - - /** - * @return Whether shutdown hook is disabled. - */ - public boolean isNoShutdownHook() { - return noShutdownHook; - } - - /** - * @return Name of command line program. - */ - public String getProgramName() { - return progName; - } - - /** - * @return Whether node is in quiet mode. - */ - public boolean isQuiet() { - return quiet; - } - - /** - * @return Success file name. - */ - public String getSuccessFile() { - return successFile; - } - - /** - * @return Whether update checker is enabled. - */ - public boolean isUpdateNotifier() { - return updateNtf; - } - - /** - * @return Active on start flag. - */ - public boolean isActiveOnStart() { - return activeOnStart; - } - - /** - * @return Class name of address resolver instance. - */ - public String getAddressResolver() { - return addrRslvr; - } - - /** - * @return Flag indicating whether cache sanity check is enabled. - */ - public boolean isCacheSanityCheckEnabled() { - return cacheSanityCheckEnabled; - } - - /** - * @return User's class loader. - */ - public String getClassLoader() { - return clsLdr; - } - - /** - * Gets consistent globally unique node ID which survives node restarts. - * - * @return Node consistent ID.a - */ - public String getConsistentId() { - return consistentId; - } - - /** - * @return Failure detection timeout in milliseconds. - */ - public Long getFailureDetectionTimeout() { - return failureDetectionTimeout; - } - - /** - * @return Ignite work directory. - */ - public String getWorkDirectory() { - return igniteWorkDir; - } - - /** - * @return Late affinity assignment flag. - */ - public boolean isLateAffinityAssignment() { - return lateAffAssignment; - } - - /** - * @return {@code True} if local jobs should be marshalled. - */ - public boolean isMarshalLocalJobs() { - return marshLocJobs; - } - - /** - * @return Job metrics update frequency in milliseconds. - */ - public long getMetricsUpdateFrequency() { - return metricsUpdateFreq; - } - - /** - * @return Failure detection timeout for client nodes in milliseconds. - */ - public Long getClientFailureDetectionTimeout() { - return clientFailureDetectionTimeout; - } - - /** - * @return Message send retries count. - */ - public int getNetworkSendRetryCount() { - return sndRetryCnt; - } - - /** - * @return Interval between message send retries. - */ - public long getNetworkSendRetryDelay() { - return sndRetryDelay; - } - - /** - * @return Base UPD port number for grid time server. - */ - public int getTimeServerPortBase() { - return timeSrvPortBase; - } - - /** - * @return Number of ports to try before server initialization fails. - */ - public int getTimeServerPortRange() { - return timeSrvPortRange; - } - - /** - * @return Thread pool keep alive time (in milliseconds) to be used in grid for utility cache messages. - */ - public long getUtilityCacheKeepAliveTime() { - return utilityCacheKeepAliveTime; - } - - /** {@inheritDoc} */ - @Override protected void writeExternalData(ObjectOutput out) throws IOException { - U.writeString(out, igniteInstanceName); - U.writeString(out, ggHome); - U.writeString(out, locHost); - U.writeString(out, marsh); - U.writeEnum(out, deployMode); - out.writeObject(clientMode); - out.writeBoolean(daemon); - out.writeBoolean(jmxRemote); - out.writeBoolean(restart); - out.writeLong(netTimeout); - U.writeString(out, log); - out.writeLong(discoStartupDelay); - U.writeString(out, mBeanSrv); - out.writeBoolean(noAscii); - out.writeBoolean(noDiscoOrder); - out.writeBoolean(noShutdownHook); - U.writeString(out, progName); - out.writeBoolean(quiet); - U.writeString(out, successFile); - out.writeBoolean(updateNtf); - out.writeBoolean(activeOnStart); - U.writeString(out, addrRslvr); - out.writeBoolean(cacheSanityCheckEnabled); - U.writeString(out, clsLdr); - U.writeString(out, consistentId); - out.writeObject(failureDetectionTimeout); - U.writeString(out, igniteWorkDir); - out.writeBoolean(lateAffAssignment); - out.writeBoolean(marshLocJobs); - out.writeLong(metricsUpdateFreq); - out.writeObject(clientFailureDetectionTimeout); - out.writeInt(sndRetryCnt); - out.writeLong(sndRetryDelay); - out.writeInt(timeSrvPortBase); - out.writeInt(timeSrvPortRange); - out.writeLong(utilityCacheKeepAliveTime); - } - - /** {@inheritDoc} */ - @Override protected void readExternalData(byte protoVer, ObjectInput in) throws IOException, ClassNotFoundException { - igniteInstanceName = U.readString(in); - ggHome = U.readString(in); - locHost = U.readString(in); - marsh = U.readString(in); - deployMode = DeploymentMode.fromOrdinal(in.readByte()); - clientMode = (Boolean)in.readObject(); - daemon = in.readBoolean(); - jmxRemote = in.readBoolean(); - restart = in.readBoolean(); - netTimeout = in.readLong(); - log = U.readString(in); - discoStartupDelay = in.readLong(); - mBeanSrv = U.readString(in); - noAscii = in.readBoolean(); - noDiscoOrder = in.readBoolean(); - noShutdownHook = in.readBoolean(); - progName = U.readString(in); - quiet = in.readBoolean(); - successFile = U.readString(in); - updateNtf = in.readBoolean(); - activeOnStart = in.readBoolean(); - addrRslvr = U.readString(in); - cacheSanityCheckEnabled = in.readBoolean(); - clsLdr = U.readString(in); - consistentId = U.readString(in); - failureDetectionTimeout = (Long)in.readObject(); - igniteWorkDir = U.readString(in); - lateAffAssignment = in.readBoolean(); - marshLocJobs = in.readBoolean(); - metricsUpdateFreq = in.readLong(); - clientFailureDetectionTimeout = (Long)in.readObject(); - sndRetryCnt = in.readInt(); - sndRetryDelay = in.readLong(); - timeSrvPortBase = in.readInt(); - timeSrvPortRange = in.readInt(); - utilityCacheKeepAliveTime = in.readLong(); - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorBasicConfiguration.class, this); - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorBinaryConfiguration.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorBinaryConfiguration.java deleted file mode 100644 index f69caf19fd845..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorBinaryConfiguration.java +++ /dev/null @@ -1,131 +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.node; - -import java.io.IOException; -import java.io.ObjectInput; -import java.io.ObjectOutput; -import java.util.List; -import org.apache.ignite.configuration.BinaryConfiguration; -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 static org.apache.ignite.internal.visor.util.VisorTaskUtils.compactClass; - -/** - * Data transfer object for configuration of binary data structures. - */ -public class VisorBinaryConfiguration extends VisorDataTransferObject { - /** */ - private static final long serialVersionUID = 0L; - - /** ID mapper. */ - private String idMapper; - - /** Name mapper. */ - private String nameMapper; - - /** Serializer. */ - private String serializer; - - /** Types. */ - private List typeCfgs; - - /** Compact footer flag. */ - private boolean compactFooter; - - /** - * Default constructor. - */ - public VisorBinaryConfiguration() { - // No-op. - } - - /** - * Create data transfer object for binary configuration. - * - * @param src Binary configuration. - */ - public VisorBinaryConfiguration(BinaryConfiguration src) { - idMapper = compactClass(src.getIdMapper()); - nameMapper = compactClass(src.getNameMapper()); - serializer = compactClass(src.getSerializer()); - compactFooter = src.isCompactFooter(); - - typeCfgs = VisorBinaryTypeConfiguration.list(src.getTypeConfigurations()); - } - - /** - * @return ID mapper. - */ - public String getIdMapper() { - return idMapper; - } - - /** - * @return Name mapper. - */ - public String getNameMapper() { - return nameMapper; - } - - /** - * @return Serializer. - */ - public String getSerializer() { - return serializer; - } - - /** - * @return Types. - */ - public List getTypeConfigurations() { - return typeCfgs; - } - - /** - * @return Compact footer flag. - */ - public boolean isCompactFooter() { - return compactFooter; - } - - /** {@inheritDoc} */ - @Override protected void writeExternalData(ObjectOutput out) throws IOException { - U.writeString(out, idMapper); - U.writeString(out, nameMapper); - U.writeString(out, serializer); - U.writeCollection(out, typeCfgs); - out.writeBoolean(compactFooter); - } - - /** {@inheritDoc} */ - @Override protected void readExternalData(byte protoVer, ObjectInput in) throws IOException, ClassNotFoundException { - idMapper = U.readString(in); - nameMapper = U.readString(in); - serializer = U.readString(in); - typeCfgs = U.readList(in); - compactFooter = in.readBoolean(); - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorBinaryConfiguration.class, this); - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorBinaryTypeConfiguration.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorBinaryTypeConfiguration.java deleted file mode 100644 index 3b575ee20c2b5..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorBinaryTypeConfiguration.java +++ /dev/null @@ -1,150 +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.node; - -import java.io.IOException; -import java.io.ObjectInput; -import java.io.ObjectOutput; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import org.apache.ignite.binary.BinaryTypeConfiguration; -import org.apache.ignite.internal.util.typedef.F; -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 static org.apache.ignite.internal.visor.util.VisorTaskUtils.compactClass; - -/** - * Data transfer object for configuration of binary type structures. - */ -public class VisorBinaryTypeConfiguration extends VisorDataTransferObject { - /** */ - private static final long serialVersionUID = 0L; - - /** Class name. */ - private String typeName; - - /** ID mapper. */ - private String idMapper; - - /** Name mapper. */ - private String nameMapper; - - /** Serializer. */ - private String serializer; - - /** Enum flag. */ - private boolean isEnum; - - /** - * Construct data transfer object for Executor configurations properties. - * - * @param cfgs Executor configurations. - * @return Executor configurations properties. - */ - public static List list(Collection cfgs) { - List res = new ArrayList<>(); - - if (!F.isEmpty(cfgs)) { - for (BinaryTypeConfiguration cfg : cfgs) - res.add(new VisorBinaryTypeConfiguration(cfg)); - } - - return res; - } - - /** - * Default constructor. - */ - public VisorBinaryTypeConfiguration() { - // No-op. - } - - /** - * Create data transfer object for binary type configuration. - * - * @param src Binary type configuration. - */ - public VisorBinaryTypeConfiguration(BinaryTypeConfiguration src) { - typeName = src.getTypeName(); - idMapper = compactClass(src.getIdMapper()); - nameMapper = compactClass(src.getNameMapper()); - serializer = compactClass(src.getSerializer()); - isEnum = src.isEnum(); - } - - /** - * @return Class name. - */ - public String getTypeName() { - return typeName; - } - - /** - * @return ID mapper. - */ - public String getIdMapper() { - return idMapper; - } - - /** - * @return Name mapper. - */ - public String getNameMapper() { - return nameMapper; - } - - /** - * @return Serializer. - */ - public String getSerializer() { - return serializer; - } - - /** - * @return Enum flag. - */ - public boolean isEnum() { - return isEnum; - } - - /** {@inheritDoc} */ - @Override protected void writeExternalData(ObjectOutput out) throws IOException { - U.writeString(out, typeName); - U.writeString(out, idMapper); - U.writeString(out, nameMapper); - U.writeString(out, serializer); - out.writeBoolean(isEnum); - } - - /** {@inheritDoc} */ - @Override protected void readExternalData(byte protoVer, ObjectInput in) throws IOException, ClassNotFoundException { - typeName = U.readString(in); - idMapper = U.readString(in); - nameMapper = U.readString(in); - serializer = U.readString(in); - isEnum = in.readBoolean(); - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorBinaryTypeConfiguration.class, this); - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorCacheKeyConfiguration.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorCacheKeyConfiguration.java deleted file mode 100644 index cbd7b55fbf7d6..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorCacheKeyConfiguration.java +++ /dev/null @@ -1,108 +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.node; - -import java.io.IOException; -import java.io.ObjectInput; -import java.io.ObjectOutput; -import java.util.ArrayList; -import java.util.List; -import org.apache.ignite.cache.CacheKeyConfiguration; -import org.apache.ignite.internal.util.typedef.F; -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 configuration of cache key data structures. - */ -public class VisorCacheKeyConfiguration extends VisorDataTransferObject { - /** */ - private static final long serialVersionUID = 0L; - - /** Type name. */ - private String typeName; - - /** Affinity key field name. */ - private String affKeyFieldName; - - /** - * Construct data transfer object for cache key configurations properties. - * - * @param cfgs Cache key configurations. - * @return Cache key configurations properties. - */ - public static List list(CacheKeyConfiguration[] cfgs) { - List res = new ArrayList<>(); - - if (!F.isEmpty(cfgs)) { - for (CacheKeyConfiguration cfg : cfgs) - res.add(new VisorCacheKeyConfiguration(cfg)); - } - - return res; - } - - /** - * Default constructor. - */ - public VisorCacheKeyConfiguration() { - // No-op. - } - - /** - * Create data transfer object for cache key configuration. - * - * @param src Cache key configuration. - */ - public VisorCacheKeyConfiguration(CacheKeyConfiguration src) { - typeName = src.getTypeName(); - affKeyFieldName = src.getAffinityKeyFieldName(); - } - - /** - * @return Type name. - */ - public String getTypeName() { - return typeName; - } - - /** - * @return Affinity key field name. - */ - public String getAffinityKeyFieldName() { - return affKeyFieldName; - } - - /** {@inheritDoc} */ - @Override protected void writeExternalData(ObjectOutput out) throws IOException { - U.writeString(out, typeName); - U.writeString(out, affKeyFieldName); - } - - /** {@inheritDoc} */ - @Override protected void readExternalData(byte protoVer, ObjectInput in) throws IOException, ClassNotFoundException { - typeName = U.readString(in); - affKeyFieldName = U.readString(in); - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorCacheKeyConfiguration.class, this); - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorCacheRebalanceCollectorJobResult.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorCacheRebalanceCollectorJobResult.java deleted file mode 100644 index 5bd818d424848..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorCacheRebalanceCollectorJobResult.java +++ /dev/null @@ -1,91 +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.node; - -import java.io.IOException; -import java.io.ObjectInput; -import java.io.ObjectOutput; -import org.apache.ignite.internal.dto.IgniteDataTransferObject; -import org.apache.ignite.internal.util.typedef.internal.S; -import org.apache.ignite.internal.util.typedef.internal.U; - -/** - * Result object for cache rebalance job. - */ -public class VisorCacheRebalanceCollectorJobResult extends IgniteDataTransferObject { - /** */ - private static final long serialVersionUID = 0L; - - /** Rebalance percent. */ - private double rebalance; - - /** Node baseline state. */ - private VisorNodeBaselineStatus baseline; - - /** - * Default constructor. - */ - public VisorCacheRebalanceCollectorJobResult() { - // No-op. - } - - /** - * @return Rebalance progress. - */ - public double getRebalance() { - return rebalance; - } - - /** - * @param rebalance Rebalance progress. - */ - public void setRebalance(double rebalance) { - this.rebalance = rebalance; - } - - /** - * @return Node baseline status. - */ - public VisorNodeBaselineStatus getBaseline() { - return baseline; - } - - /** - * @param baseline Node baseline status. - */ - public void setBaseline(VisorNodeBaselineStatus baseline) { - this.baseline = baseline; - } - - /** {@inheritDoc} */ - @Override protected void writeExternalData(ObjectOutput out) throws IOException { - out.writeDouble(rebalance); - U.writeEnum(out, baseline); - } - - /** {@inheritDoc} */ - @Override protected void readExternalData(byte protoVer, ObjectInput in) throws IOException, ClassNotFoundException { - rebalance = in.readDouble(); - baseline = VisorNodeBaselineStatus.fromOrdinal(in.readByte()); - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorCacheRebalanceCollectorJobResult.class, this); - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorCacheRebalanceCollectorTask.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorCacheRebalanceCollectorTask.java deleted file mode 100644 index 484150ecca08d..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorCacheRebalanceCollectorTask.java +++ /dev/null @@ -1,199 +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.node; - -import java.util.Collection; -import java.util.List; -import org.apache.ignite.cache.CacheMetrics; -import org.apache.ignite.cluster.BaselineNode; -import org.apache.ignite.compute.ComputeJobResult; -import org.apache.ignite.internal.cluster.IgniteClusterEx; -import org.apache.ignite.internal.processors.cache.CacheGroupContext; -import org.apache.ignite.internal.processors.cache.GridCacheAdapter; -import org.apache.ignite.internal.processors.cache.GridCacheProcessor; -import org.apache.ignite.internal.processors.cache.GridCacheUtils; -import org.apache.ignite.internal.processors.task.GridInternal; -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.VisorMultiNodeTask; -import org.jetbrains.annotations.Nullable; - -import static org.apache.ignite.internal.visor.node.VisorNodeBaselineStatus.BASELINE_NOT_AVAILABLE; -import static org.apache.ignite.internal.visor.node.VisorNodeBaselineStatus.NODE_IN_BASELINE; -import static org.apache.ignite.internal.visor.node.VisorNodeBaselineStatus.NODE_NOT_IN_BASELINE; -import static org.apache.ignite.internal.visor.util.VisorTaskUtils.MINIMAL_REBALANCE; -import static org.apache.ignite.internal.visor.util.VisorTaskUtils.NOTHING_TO_REBALANCE; -import static org.apache.ignite.internal.visor.util.VisorTaskUtils.REBALANCE_COMPLETE; -import static org.apache.ignite.internal.visor.util.VisorTaskUtils.REBALANCE_NOT_AVAILABLE; -import static org.apache.ignite.internal.visor.util.VisorTaskUtils.isProxyCache; -import static org.apache.ignite.internal.visor.util.VisorTaskUtils.isRestartingCache; -import static org.apache.ignite.internal.visor.util.VisorTaskUtils.log; - -/** - * Collects topology rebalance metrics. - */ -@GridInternal -public class VisorCacheRebalanceCollectorTask extends VisorMultiNodeTask { - /** */ - private static final long serialVersionUID = 0L; - - /** {@inheritDoc} */ - @Override protected VisorCacheRebalanceCollectorJob job(VisorCacheRebalanceCollectorTaskArg arg) { - return new VisorCacheRebalanceCollectorJob(arg, debug); - } - - /** {@inheritDoc} */ - @Nullable @Override protected VisorCacheRebalanceCollectorTaskResult reduce0(List results) { - return reduce(new VisorCacheRebalanceCollectorTaskResult(), results); - } - - /** - * @param taskRes Task result. - * @param results Results. - * @return Topology rebalance metrics collector task result. - */ - protected VisorCacheRebalanceCollectorTaskResult reduce( - VisorCacheRebalanceCollectorTaskResult taskRes, - List results - ) { - for (ComputeJobResult res : results) { - VisorCacheRebalanceCollectorJobResult jobRes = res.getData(); - - if (jobRes != null) { - if (res.getException() == null) - taskRes.getRebalance().put(res.getNode().id(), jobRes.getRebalance()); - - taskRes.getBaseline().put(res.getNode().id(), jobRes.getBaseline()); - } - } - - return taskRes; - } - - /** - * Job that collects rebalance metrics. - */ - private static class VisorCacheRebalanceCollectorJob - extends VisorJob { - /** */ - private static final long serialVersionUID = 0L; - - /** - * Create job with given argument. - * - * @param arg Job argument. - * @param debug Debug flag. - */ - private VisorCacheRebalanceCollectorJob(VisorCacheRebalanceCollectorTaskArg arg, boolean debug) { - super(arg, debug); - } - - /** {@inheritDoc} */ - @Override protected VisorCacheRebalanceCollectorJobResult run(VisorCacheRebalanceCollectorTaskArg arg) { - VisorCacheRebalanceCollectorJobResult res = new VisorCacheRebalanceCollectorJobResult(); - - long start0 = U.currentTimeMillis(); - - try { - int partitions = 0; - double total = 0; - double ready = 0; - - GridCacheProcessor cacheProc = ignite.context().cache(); - - boolean rebalanceInProgress = false; - - for (CacheGroupContext grp: cacheProc.cacheGroups()) { - String cacheName = grp.config().getName(); - - if (isProxyCache(ignite, cacheName) || isRestartingCache(ignite, cacheName)) - continue; - - try { - GridCacheAdapter ca = cacheProc.internalCache(cacheName); - - if (ca == null || !ca.context().started()) - continue; - - CacheMetrics cm = ca.localMetrics(); - - partitions += cm.getTotalPartitionsCount(); - - long keysTotal = cm.getEstimatedRebalancingKeys(); - long keysReady = cm.getRebalancedKeys(); - - if (keysReady >= keysTotal) - keysReady = Math.max(keysTotal - 1, 0); - - total += keysTotal; - ready += keysReady; - - if (cm.getRebalancingPartitionsCount() > 0) - rebalanceInProgress = true; - } - catch (IllegalStateException | IllegalArgumentException e) { - if (debug && ignite.log() != null) - ignite.log().error("Ignored cache group: " + grp.cacheOrGroupName(), e); - } - } - - if (partitions == 0) - res.setRebalance(NOTHING_TO_REBALANCE); - else if (total == 0 && rebalanceInProgress) - res.setRebalance(MINIMAL_REBALANCE); - else - res.setRebalance(total > 0 && rebalanceInProgress ? Math.max(ready / total, MINIMAL_REBALANCE) : REBALANCE_COMPLETE); - } - catch (Exception e) { - res.setRebalance(REBALANCE_NOT_AVAILABLE); - - ignite.log().error("Failed to collect rebalance metrics", e); - } - - if (GridCacheUtils.isPersistenceEnabled(ignite.configuration())) { - IgniteClusterEx cluster = ignite.cluster(); - - Object consistentId = ignite.localNode().consistentId(); - - Collection baseline = cluster.currentBaselineTopology(); - - if (baseline != null) { - boolean inBaseline = baseline.stream().anyMatch(n -> consistentId.equals(n.consistentId())); - - res.setBaseline(inBaseline ? NODE_IN_BASELINE : NODE_NOT_IN_BASELINE); - } - else - res.setBaseline(BASELINE_NOT_AVAILABLE); - } - else - res.setBaseline(BASELINE_NOT_AVAILABLE); - - if (debug) - log(ignite.log(), "Collected rebalance metrics", getClass(), start0); - - return res; - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorCacheRebalanceCollectorJob.class, this); - } - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorCacheRebalanceCollectorTaskArg.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorCacheRebalanceCollectorTaskArg.java deleted file mode 100644 index d97fd50192572..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorCacheRebalanceCollectorTaskArg.java +++ /dev/null @@ -1,54 +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.node; - -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.visor.VisorDataTransferObject; - -/** - * Argument for {@link VisorCacheRebalanceCollectorTask} task. - */ -public class VisorCacheRebalanceCollectorTaskArg extends VisorDataTransferObject { - /** */ - private static final long serialVersionUID = 0L; - - /** - * Default constructor. - */ - public VisorCacheRebalanceCollectorTaskArg() { - // No-op. - } - - /** {@inheritDoc} */ - @Override protected void writeExternalData(ObjectOutput out) throws IOException { - // No-op. - } - - /** {@inheritDoc} */ - @Override protected void readExternalData(byte protoVer, ObjectInput in) throws IOException, ClassNotFoundException { - // No-op. - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorCacheRebalanceCollectorTaskArg.class, this); - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorCacheRebalanceCollectorTaskResult.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorCacheRebalanceCollectorTaskResult.java deleted file mode 100644 index 1305cd2df87eb..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorCacheRebalanceCollectorTaskResult.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.node; - -import java.io.IOException; -import java.io.ObjectInput; -import java.io.ObjectOutput; -import java.util.HashMap; -import java.util.Map; -import java.util.UUID; -import org.apache.ignite.internal.dto.IgniteDataTransferObject; -import org.apache.ignite.internal.util.typedef.internal.S; -import org.apache.ignite.internal.util.typedef.internal.U; - -/** - * Result object for {@link VisorCacheRebalanceCollectorTask} task. - */ -public class VisorCacheRebalanceCollectorTaskResult extends IgniteDataTransferObject { - /** */ - private static final long serialVersionUID = 0L; - - /** Rebalance state on nodes. */ - private Map rebalance = new HashMap<>(); - - /** Nodes baseline status. */ - private Map baseline = new HashMap<>(); - - /** - * Default constructor. - */ - public VisorCacheRebalanceCollectorTaskResult() { - // No-op. - } - - /** - * @return Rebalance on nodes. - */ - public Map getRebalance() { - return rebalance; - } - - /** - * @return Baseline. - */ - public Map getBaseline() { - return baseline; - } - - /** - * Add specified results. - * - * @param res Results to add. - */ - public void add(VisorCacheRebalanceCollectorTaskResult res) { - assert res != null; - - rebalance.putAll(res.getRebalance()); - baseline.putAll(res.getBaseline()); - } - - /** {@inheritDoc} */ - @Override protected void writeExternalData(ObjectOutput out) throws IOException { - U.writeMap(out, rebalance); - U.writeMap(out, baseline); - } - - /** {@inheritDoc} */ - @Override protected void readExternalData(byte protoVer, ObjectInput in) throws IOException, ClassNotFoundException { - rebalance = U.readMap(in); - baseline = U.readMap(in); - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorCacheRebalanceCollectorTaskResult.class, this); - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorClientConnectorConfiguration.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorClientConnectorConfiguration.java deleted file mode 100644 index 22704ab1fd071..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorClientConnectorConfiguration.java +++ /dev/null @@ -1,281 +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.node; - -import java.io.IOException; -import java.io.ObjectInput; -import java.io.ObjectOutput; -import org.apache.ignite.configuration.ClientConnectorConfiguration; -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; - -/** - * Data transfer object for client connector configuration. - */ -public class VisorClientConnectorConfiguration extends VisorDataTransferObject { - /** */ - private static final long serialVersionUID = 0L; - - /** Host. */ - private String host; - - /** Port. */ - private int port; - - /** Port range. */ - private int portRange; - - /** Max number of opened cursors per connection. */ - private int maxOpenCursorsPerConn; - - /** Socket send buffer size. */ - private int sockSndBufSize; - - /** Socket receive buffer size. */ - private int sockRcvBufSize; - - /** TCP no delay. */ - private boolean tcpNoDelay; - - /** Thread pool size. */ - private int threadPoolSize; - - /** Idle timeout. */ - private long idleTimeout; - - /** JDBC connections enabled flag. */ - private boolean jdbcEnabled; - - /** ODBC connections enabled flag. */ - private boolean odbcEnabled; - - /** JDBC connections enabled flag. */ - private boolean thinCliEnabled; - - /** SSL enable flag, default is disabled. */ - private boolean sslEnabled; - - /** If to use SSL context factory from Ignite configuration. */ - private boolean useIgniteSslCtxFactory; - - /** SSL need client auth flag. */ - private boolean sslClientAuth; - - /** SSL connection factory class name. */ - private String sslCtxFactory; - - /** - * Default constructor. - */ - public VisorClientConnectorConfiguration() { - // No-op. - } - - /** - * Create data transfer object for Sql connector configuration. - * - * @param cfg Sql connector configuration. - */ - public VisorClientConnectorConfiguration(ClientConnectorConfiguration cfg) { - host = cfg.getHost(); - port = cfg.getPort(); - portRange = cfg.getPortRange(); - maxOpenCursorsPerConn = cfg.getMaxOpenCursorsPerConnection(); - sockSndBufSize = cfg.getSocketSendBufferSize(); - sockRcvBufSize = cfg.getSocketReceiveBufferSize(); - tcpNoDelay = cfg.isTcpNoDelay(); - threadPoolSize = cfg.getThreadPoolSize(); - idleTimeout = cfg.getIdleTimeout(); - jdbcEnabled = cfg.isJdbcEnabled(); - odbcEnabled = cfg.isOdbcEnabled(); - thinCliEnabled = cfg.isThinClientEnabled(); - sslEnabled = cfg.isSslEnabled(); - useIgniteSslCtxFactory = cfg.isUseIgniteSslContextFactory(); - sslClientAuth = cfg.isSslClientAuth(); - sslCtxFactory = compactClass(cfg.getSslContextFactory()); - } - - /** - * @return Host. - */ - @Nullable public String getHost() { - return host; - } - - /** - * @return Port. - */ - public int getPort() { - return port; - } - - /** - * @return Port range. - */ - public int getPortRange() { - return portRange; - } - - /** - * @return Maximum number of opened cursors. - */ - public int getMaxOpenCursorsPerConnection() { - return maxOpenCursorsPerConn; - } - - /** - * @return Socket send buffer size in bytes. - */ - public int getSocketSendBufferSize() { - return sockSndBufSize; - } - - /** - * @return Socket receive buffer size in bytes. - */ - public int getSocketReceiveBufferSize() { - return sockRcvBufSize; - } - - /** - * @return TCP NO_DELAY flag. - */ - public boolean isTcpNoDelay() { - return tcpNoDelay; - } - - /** - * @return Thread pool that is in charge of processing SQL requests. - */ - public int getThreadPoolSize() { - return threadPoolSize; - } - - /** - * @return Idle timeout. - */ - public long getIdleTimeout() { - return idleTimeout; - } - - /** - * @return JDBC connections enabled flag. - */ - public boolean isJdbcEnabled() { - return jdbcEnabled; - } - - /** - * @return ODBC connections enabled flag. - */ - public boolean isOdbcEnabled() { - return odbcEnabled; - } - - /** - * @return JDBC connections enabled flag. - */ - public boolean isThinClientEnabled() { - return thinCliEnabled; - } - - /** - * @return SSL enable flag, default is disabled. - */ - public boolean isSslEnabled() { - return sslEnabled; - } - - /** - * @return If to use SSL context factory from Ignite configuration. - */ - public boolean isUseIgniteSslContextFactory() { - return useIgniteSslCtxFactory; - } - - /** - * @return SSL need client auth flag. - */ - public boolean isSslClientAuth() { - return sslClientAuth; - } - - /** - * @return SSL connection factory. - */ - public String getSslContextFactory() { - return sslCtxFactory; - } - - /** {@inheritDoc} */ - @Override public byte getProtocolVersion() { - return V2; - } - - /** {@inheritDoc} */ - @Override protected void writeExternalData(ObjectOutput out) throws IOException { - U.writeString(out, host); - out.writeInt(port); - out.writeInt(portRange); - out.writeInt(maxOpenCursorsPerConn); - out.writeInt(sockSndBufSize); - out.writeInt(sockRcvBufSize); - out.writeBoolean(tcpNoDelay); - out.writeInt(threadPoolSize); - out.writeLong(idleTimeout); - out.writeBoolean(jdbcEnabled); - out.writeBoolean(odbcEnabled); - out.writeBoolean(thinCliEnabled); - out.writeBoolean(sslEnabled); - out.writeBoolean(useIgniteSslCtxFactory); - out.writeBoolean(sslClientAuth); - U.writeString(out, sslCtxFactory); - } - - /** {@inheritDoc} */ - @Override protected void readExternalData(byte protoVer, ObjectInput in) throws IOException, ClassNotFoundException { - host = U.readString(in); - port = in.readInt(); - portRange = in.readInt(); - maxOpenCursorsPerConn = in.readInt(); - sockSndBufSize = in.readInt(); - sockRcvBufSize = in.readInt(); - tcpNoDelay = in.readBoolean(); - threadPoolSize = in.readInt(); - - if (protoVer > V1) { - idleTimeout = in.readLong(); - jdbcEnabled = in.readBoolean(); - odbcEnabled = in.readBoolean(); - thinCliEnabled = in.readBoolean(); - sslEnabled = in.readBoolean(); - useIgniteSslCtxFactory = in.readBoolean(); - sslClientAuth = in.readBoolean(); - sslCtxFactory = U.readString(in); - } - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorClientConnectorConfiguration.class, this); - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorDataRegionConfiguration.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorDataRegionConfiguration.java deleted file mode 100644 index 179e7894fc0b8..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorDataRegionConfiguration.java +++ /dev/null @@ -1,238 +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.node; - -import java.io.IOException; -import java.io.ObjectInput; -import java.io.ObjectOutput; -import java.util.ArrayList; -import java.util.List; -import org.apache.ignite.configuration.DataPageEvictionMode; -import org.apache.ignite.configuration.DataRegionConfiguration; -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 data region configuration. - */ -public class VisorDataRegionConfiguration extends VisorDataTransferObject { - /** */ - private static final long serialVersionUID = 0L; - - /** Unique name of DataRegion. */ - private String name; - - /** Initial memory region size defined by this memory policy. */ - private long initSize; - - /** Maximum memory region size defined by this memory policy. */ - private long maxSize; - - /** Path for memory mapped file. */ - private String swapPath; - - /** An algorithm for memory pages eviction. */ - private DataPageEvictionMode pageEvictionMode; - - /** A threshold for memory pages eviction initiation. */ - private double evictionThreshold; - - /** Minimum number of empty pages in reuse lists. */ - private int emptyPagesPoolSize; - - /** Enable memory metrics collection for this data region. */ - private boolean metricsEnabled; - - /** Number of sub-intervals. */ - private int metricsSubIntervalCount; - - /** Time interval over which allocation rate is calculated. */ - private long metricsRateTimeInterval; - - /** Enable Ignite Native Persistence. */ - private boolean persistenceEnabled; - - /** Temporary buffer size for checkpoints in bytes. */ - private long checkpointPageBufSize; - - /** - * Default constructor. - */ - public VisorDataRegionConfiguration() { - // No-op. - } - - /** - * Constructor. - * - * @param plc Data region configuration. - */ - public VisorDataRegionConfiguration(DataRegionConfiguration plc) { - assert plc != null; - - name = plc.getName(); - initSize = plc.getInitialSize(); - maxSize = plc.getMaxSize(); - swapPath = plc.getSwapPath(); - pageEvictionMode = plc.getPageEvictionMode(); - evictionThreshold = plc.getEvictionThreshold(); - emptyPagesPoolSize = plc.getEmptyPagesPoolSize(); - metricsEnabled = plc.isMetricsEnabled(); - metricsSubIntervalCount = plc.getMetricsSubIntervalCount(); - metricsRateTimeInterval = plc.getMetricsRateTimeInterval(); - persistenceEnabled = plc.isPersistenceEnabled(); - checkpointPageBufSize = plc.getCheckpointPageBufferSize(); - } - - /** - * @param regCfgs Array of data region configurations. - * @return Collection of DTO objects. - */ - public static List from(DataRegionConfiguration[] regCfgs) { - List res = new ArrayList<>(); - - if (regCfgs != null) { - for (DataRegionConfiguration plc: regCfgs) - res.add(new VisorDataRegionConfiguration(plc)); - } - - return res; - } - - /** - * @return Unique name of DataRegion. - */ - public String getName() { - return name; - } - - /** - * @return Maximum memory region size defined by this memory policy. - */ - public long getMaxSize() { - return maxSize; - } - - /** - * @return Initial memory region size defined by this memory policy. - */ - public long getInitialSize() { - return initSize; - } - - /** - * @return Path for memory mapped file. - */ - public String getSwapPath() { - return swapPath; - } - - /** - * @return Memory pages eviction algorithm. {@link DataPageEvictionMode#DISABLED} used by default. - */ - public DataPageEvictionMode getPageEvictionMode() { - return pageEvictionMode; - } - - /** - * @return Memory pages eviction threshold. - */ - public double getEvictionThreshold() { - return evictionThreshold; - } - - /** - * @return Minimum number of empty pages in reuse list. - */ - public int getEmptyPagesPoolSize() { - return emptyPagesPoolSize; - } - - /** - * @return Metrics enabled flag. - */ - public boolean isMetricsEnabled() { - return metricsEnabled; - } - - /** - * @return Number of sub intervals. - */ - public int getMetricsSubIntervalCount() { - return metricsSubIntervalCount; - } - - /** - * @return Time interval over which allocation rate is calculated. - */ - public long getMetricsRateTimeInterval() { - return metricsRateTimeInterval; - } - - /** - * @return Persistence enabled flag. - */ - public boolean isPersistenceEnabled() { - return persistenceEnabled; - } - - /** - * @return Amount of memory allocated for a checkpoint temporary buffer in bytes. - */ - public long getCheckpointPageBufferSize() { - return checkpointPageBufSize; - } - - /** {@inheritDoc} */ - @Override protected void writeExternalData(ObjectOutput out) throws IOException { - U.writeString(out, name); - out.writeLong(initSize); - out.writeLong(maxSize); - U.writeString(out, swapPath); - U.writeEnum(out, pageEvictionMode); - out.writeDouble(evictionThreshold); - out.writeInt(emptyPagesPoolSize); - out.writeBoolean(metricsEnabled); - out.writeInt(metricsSubIntervalCount); - out.writeLong(metricsRateTimeInterval); - out.writeBoolean(persistenceEnabled); - out.writeLong(checkpointPageBufSize); - } - - /** {@inheritDoc} */ - @Override protected void readExternalData(byte protoVer, ObjectInput in) throws IOException, ClassNotFoundException { - name = U.readString(in); - initSize = in.readLong(); - maxSize = in.readLong(); - swapPath = U.readString(in); - pageEvictionMode = DataPageEvictionMode.fromOrdinal(in.readByte()); - evictionThreshold = in.readDouble(); - emptyPagesPoolSize = in.readInt(); - metricsEnabled = in.readBoolean(); - metricsSubIntervalCount = in.readInt(); - metricsRateTimeInterval = in.readLong(); - persistenceEnabled = in.readBoolean(); - checkpointPageBufSize = in.readLong(); - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorDataRegionConfiguration.class, this); - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorDataStorageConfiguration.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorDataStorageConfiguration.java deleted file mode 100644 index 8dad47ce54430..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorDataStorageConfiguration.java +++ /dev/null @@ -1,491 +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.node; - -import java.io.IOException; -import java.io.ObjectInput; -import java.io.ObjectOutput; -import java.util.List; -import org.apache.ignite.configuration.CheckpointWriteOrder; -import org.apache.ignite.configuration.DataRegionConfiguration; -import org.apache.ignite.configuration.DataStorageConfiguration; -import org.apache.ignite.configuration.WALMode; -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 static org.apache.ignite.internal.visor.util.VisorTaskUtils.compactClass; - -/** - * Data transfer object for data store configuration. - */ -public class VisorDataStorageConfiguration extends VisorDataTransferObject { - /** */ - private static final long serialVersionUID = 0L; - - /** Size of a memory chunk reserved for system cache initially. */ - private long sysRegionInitSize; - - /** Size of memory for system cache. */ - private long sysRegionMaxSize; - - /** Page size. */ - private int pageSize; - - /** Concurrency level. */ - private int concLvl; - - /** Configuration of default data region. */ - private VisorDataRegionConfiguration dfltDataRegCfg; - - /** Memory policies. */ - private List dataRegCfgs; - - /** */ - private String storagePath; - - /** Checkpointing frequency. */ - private long checkpointFreq; - - /** Lock wait time. */ - private long lockWaitTime; - - /** */ - private int checkpointThreads; - - /** Checkpoint write order. */ - private CheckpointWriteOrder checkpointWriteOrder; - - /** */ - private int walHistSize; - - /** Number of work WAL segments. */ - private int walSegments; - - /** Number of WAL segments to keep. */ - private int walSegmentSize; - - /** WAL persistence path. */ - private String walPath; - - /** WAL archive path. */ - private String walArchivePath; - - /** Metrics enabled flag. */ - private boolean metricsEnabled; - - /** Wal mode. */ - private WALMode walMode; - - /** WAl thread local buffer size. */ - private int walTlbSize; - - /** Wal flush frequency. */ - private long walFlushFreq; - - /** Wal fsync delay in nanoseconds. */ - private long walFsyncDelay; - - /** Wal record iterator buffer size. */ - private int walRecordIterBuffSize; - - /** Always write full pages. */ - private boolean alwaysWriteFullPages; - - /** Factory to provide I/O interface for files */ - private String fileIOFactory; - - /** Number of sub-intervals. */ - private int metricsSubIntervalCount; - - /** Time interval (in milliseconds) for rate-based metrics. */ - private long metricsRateTimeInterval; - - /** Time interval of inactivity (in milliseconds) for running auto archiving for incompletely WAL segment. */ - private long walAutoArchiveAfterInactivity; - - /** Time interval (in milliseconds) for running auto archiving for incompletely WAL segment. */ - private long walForceArchiveTimeout; - - /** If true, threads that generate dirty pages too fast during ongoing checkpoint will be throttled. */ - private boolean writeThrottlingEnabled; - - /** Size of WAL buffer. */ - private int walBufSize; - - /** If true, system filters and compresses WAL archive in background. */ - private boolean walCompactionEnabled; - - /** - * Default constructor. - */ - public VisorDataStorageConfiguration() { - // No-op. - } - - /** - * Constructor. - * - * @param cfg Data storage configuration. - */ - public VisorDataStorageConfiguration(DataStorageConfiguration cfg) { - assert cfg != null; - - sysRegionInitSize = cfg.getSystemDataRegionConfiguration().getInitialSize(); - sysRegionMaxSize = cfg.getSystemDataRegionConfiguration().getMaxSize(); - pageSize = cfg.getPageSize(); - concLvl = cfg.getConcurrencyLevel(); - - DataRegionConfiguration dfltRegion = cfg.getDefaultDataRegionConfiguration(); - - if (dfltRegion != null) - dfltDataRegCfg = new VisorDataRegionConfiguration(dfltRegion); - - dataRegCfgs = VisorDataRegionConfiguration.from(cfg.getDataRegionConfigurations()); - - storagePath = cfg.getStoragePath(); - checkpointFreq = cfg.getCheckpointFrequency(); - lockWaitTime = cfg.getLockWaitTime(); - checkpointThreads = cfg.getCheckpointThreads(); - checkpointWriteOrder = cfg.getCheckpointWriteOrder(); - walHistSize = cfg.getWalHistorySize(); - walSegments = cfg.getWalSegments(); - walSegmentSize = cfg.getWalSegmentSize(); - walPath = cfg.getWalPath(); - walArchivePath = cfg.getWalArchivePath(); - metricsEnabled = cfg.isMetricsEnabled(); - walMode = cfg.getWalMode(); - walTlbSize = cfg.getWalThreadLocalBufferSize(); - walBufSize = cfg.getWalBufferSize(); - walFlushFreq = cfg.getWalFlushFrequency(); - walFsyncDelay = cfg.getWalFsyncDelayNanos(); - walRecordIterBuffSize = cfg.getWalRecordIteratorBufferSize(); - alwaysWriteFullPages = cfg.isAlwaysWriteFullPages(); - fileIOFactory = compactClass(cfg.getFileIOFactory()); - metricsSubIntervalCount = cfg.getMetricsSubIntervalCount(); - metricsRateTimeInterval = cfg.getMetricsRateTimeInterval(); - walAutoArchiveAfterInactivity = cfg.getWalAutoArchiveAfterInactivity(); - walForceArchiveTimeout = cfg.getWalForceArchiveTimeout(); - writeThrottlingEnabled = cfg.isWriteThrottlingEnabled(); - walCompactionEnabled = cfg.isWalCompactionEnabled(); - } - - /** - * @return Initial size in bytes. - */ - public long getSystemRegionInitialSize() { - return sysRegionInitSize; - } - - /** - * @return Maximum in bytes. - */ - public long getSystemRegionMaxSize() { - return sysRegionMaxSize; - } - - /** - * @return Page size in bytes. - */ - public int getPageSize() { - return pageSize; - } - - /** - * @return Mapping table concurrency level. - */ - public int getConcurrencyLevel() { - return concLvl; - } - - /** - * @return Configuration of default data region. - */ - public VisorDataRegionConfiguration getDefaultDataRegionConfiguration() { - return dfltDataRegCfg; - } - - /** - * @return Array of configured data regions. - */ - public List getDataRegionConfigurations() { - return dataRegCfgs; - } - - /** - * @return Path the root directory where the Persistent Store will persist data and indexes. - */ - public String getStoragePath() { - return storagePath; - } - - /** - * @return Checkpointing frequency in milliseconds. - */ - public long getCheckpointFrequency() { - return checkpointFreq; - } - - /** - * @return Number of checkpointing threads. - */ - public int getCheckpointThreads() { - return checkpointThreads; - } - - /** - * @return Checkpoint write order. - */ - public CheckpointWriteOrder getCheckpointWriteOrder() { - return checkpointWriteOrder; - } - - /** - * @return Time for wait. - */ - public long getLockWaitTime() { - return lockWaitTime; - } - - /** - * @return Number of WAL segments to keep after a checkpoint is finished. - */ - public int getWalHistorySize() { - return walHistSize; - } - - /** - * @return Number of work WAL segments. - */ - public int getWalSegments() { - return walSegments; - } - - /** - * @return WAL segment size. - */ - public int getWalSegmentSize() { - return walSegmentSize; - } - - /** - * @return WAL persistence path, absolute or relative to Ignite work directory. - */ - public String getWalPath() { - return walPath; - } - - /** - * @return WAL archive directory. - */ - public String getWalArchivePath() { - return walArchivePath; - } - - /** - * @return Metrics enabled flag. - */ - public boolean isMetricsEnabled() { - return metricsEnabled; - } - - /** - * @return Time interval in milliseconds. - */ - public long getMetricsRateTimeInterval() { - return metricsRateTimeInterval; - } - - /** - * @return The number of sub-intervals for history tracking. - */ - public int getMetricsSubIntervalCount() { - return metricsSubIntervalCount; - } - - /** - * @return WAL mode. - */ - public WALMode getWalMode() { - return walMode; - } - - /** - * @return Thread local buffer size. - */ - public int getWalThreadLocalBufferSize() { - return walTlbSize; - } - - /** - * @return Flush frequency. - */ - public long getWalFlushFrequency() { - return walFlushFreq; - } - - /** - * @return Gets the fsync delay, in nanoseconds. - */ - public long getWalFsyncDelayNanos() { - return walFsyncDelay; - } - - /** - * @return Record iterator buffer size. - */ - public int getWalRecordIteratorBufferSize() { - return walRecordIterBuffSize; - } - - /** - * @return Flag indicating whether full pages should be always written. - */ - public boolean isAlwaysWriteFullPages() { - return alwaysWriteFullPages; - } - - /** - * @return File I/O factory class name. - */ - public String getFileIOFactory() { - return fileIOFactory; - } - - /** - * @return Time in millis. - */ - public long getWalAutoArchiveAfterInactivity() { - return walAutoArchiveAfterInactivity; - } - - /** - * @return Time in millis. - */ - public long getWalForceArchiveTimeout() { - return walForceArchiveTimeout; - } - - /** - * @return Flag indicating whether write throttling is enabled. - */ - public boolean isWriteThrottlingEnabled() { - return writeThrottlingEnabled; - } - - /** - * @return Size of WAL buffer. - */ - public int getWalBufferSize() { - return walBufSize; - } - - /** - * @return If true, system filters and compresses WAL archive in background - */ - public boolean isWalCompactionEnabled() { - return walCompactionEnabled; - } - - /** {@inheritDoc} */ - @Override public byte getProtocolVersion() { - return V2; - } - - /** {@inheritDoc} */ - @Override protected void writeExternalData(ObjectOutput out) throws IOException { - out.writeLong(sysRegionInitSize); - out.writeLong(sysRegionMaxSize); - out.writeInt(pageSize); - out.writeInt(concLvl); - out.writeObject(dfltDataRegCfg); - U.writeCollection(out, dataRegCfgs); - U.writeString(out, storagePath); - out.writeLong(checkpointFreq); - out.writeLong(lockWaitTime); - out.writeLong(0); // Write stub for removed checkpointPageBufSize. - out.writeInt(checkpointThreads); - U.writeEnum(out, checkpointWriteOrder); - out.writeInt(walHistSize); - out.writeInt(walSegments); - out.writeInt(walSegmentSize); - U.writeString(out, walPath); - U.writeString(out, walArchivePath); - out.writeBoolean(metricsEnabled); - U.writeEnum(out, walMode); - out.writeInt(walTlbSize); - out.writeLong(walFlushFreq); - out.writeLong(walFsyncDelay); - out.writeInt(walRecordIterBuffSize); - out.writeBoolean(alwaysWriteFullPages); - U.writeString(out, fileIOFactory); - out.writeInt(metricsSubIntervalCount); - out.writeLong(metricsRateTimeInterval); - out.writeLong(walAutoArchiveAfterInactivity); - out.writeBoolean(writeThrottlingEnabled); - out.writeInt(walBufSize); - out.writeBoolean(walCompactionEnabled); - out.writeLong(walForceArchiveTimeout); - } - - /** {@inheritDoc} */ - @Override protected void readExternalData(byte protoVer, ObjectInput in) throws IOException, ClassNotFoundException { - sysRegionInitSize = in.readLong(); - sysRegionMaxSize = in.readLong(); - pageSize = in.readInt(); - concLvl = in.readInt(); - dfltDataRegCfg = (VisorDataRegionConfiguration)in.readObject(); - dataRegCfgs = U.readList(in); - storagePath = U.readString(in); - checkpointFreq = in.readLong(); - lockWaitTime = in.readLong(); - in.readLong(); // Read stub for removed checkpointPageBufSize. - checkpointThreads = in.readInt(); - checkpointWriteOrder = CheckpointWriteOrder.fromOrdinal(in.readByte()); - walHistSize = in.readInt(); - walSegments = in.readInt(); - walSegmentSize = in.readInt(); - walPath = U.readString(in); - walArchivePath = U.readString(in); - metricsEnabled = in.readBoolean(); - walMode = WALMode.fromOrdinal(in.readByte()); - walTlbSize = in.readInt(); - walFlushFreq = in.readLong(); - walFsyncDelay = in.readLong(); - walRecordIterBuffSize = in.readInt(); - alwaysWriteFullPages = in.readBoolean(); - fileIOFactory = U.readString(in); - metricsSubIntervalCount = in.readInt(); - metricsRateTimeInterval = in.readLong(); - walAutoArchiveAfterInactivity = in.readLong(); - writeThrottlingEnabled = in.readBoolean(); - - if (protoVer > V1) { - walBufSize = in.readInt(); - walCompactionEnabled = in.readBoolean(); - } - - if (protoVer >= V5) - walForceArchiveTimeout = in.readLong(); - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorDataStorageConfiguration.class, this); - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorExecutorConfiguration.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorExecutorConfiguration.java deleted file mode 100644 index 82eaf0b937ebb..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorExecutorConfiguration.java +++ /dev/null @@ -1,108 +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.node; - -import java.io.IOException; -import java.io.ObjectInput; -import java.io.ObjectOutput; -import java.util.ArrayList; -import java.util.List; -import org.apache.ignite.configuration.ExecutorConfiguration; -import org.apache.ignite.internal.util.typedef.F; -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 configuration of executor data structures. - */ -public class VisorExecutorConfiguration extends VisorDataTransferObject { - /** */ - private static final long serialVersionUID = 0L; - - /** Thread pool name. */ - private String name; - - /** Thread pool size. */ - private int size; - - /** - * Construct data transfer object for Executor configurations properties. - * - * @param cfgs Executor configurations. - * @return Executor configurations properties. - */ - public static List list(ExecutorConfiguration[] cfgs) { - List res = new ArrayList<>(); - - if (!F.isEmpty(cfgs)) { - for (ExecutorConfiguration cfg : cfgs) - res.add(new VisorExecutorConfiguration(cfg)); - } - - return res; - } - - /** - * Default constructor. - */ - public VisorExecutorConfiguration() { - // No-op. - } - - /** - * Create data transfer object for executor configuration. - * - * @param src Executor configuration. - */ - public VisorExecutorConfiguration(ExecutorConfiguration src) { - name = src.getName(); - size = src.getSize(); - } - - /** - * @return Executor name. - */ - public String getName() { - return name; - } - - /** - * @return Thread pool size. - */ - public int getSize() { - return size; - } - - /** {@inheritDoc} */ - @Override protected void writeExternalData(ObjectOutput out) throws IOException { - U.writeString(out, name); - out.writeInt(size); - } - - /** {@inheritDoc} */ - @Override protected void readExternalData(byte protoVer, ObjectInput in) throws IOException, ClassNotFoundException { - name = U.readString(in); - size = in.readInt(); - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorExecutorConfiguration.class, this); - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorExecutorServiceConfiguration.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorExecutorServiceConfiguration.java deleted file mode 100644 index 8fa023f6ba7a1..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorExecutorServiceConfiguration.java +++ /dev/null @@ -1,269 +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.node; - -import java.io.IOException; -import java.io.ObjectInput; -import java.io.ObjectOutput; -import java.util.List; -import org.apache.ignite.configuration.ClientConnectorConfiguration; -import org.apache.ignite.configuration.ConnectorConfiguration; -import org.apache.ignite.configuration.IgniteConfiguration; -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 node executors configuration properties. - */ -public class VisorExecutorServiceConfiguration extends VisorDataTransferObject { - /** */ - private static final long serialVersionUID = 0L; - - /** Public pool size. */ - private int pubPoolSize; - - /** System pool size. */ - private int sysPoolSz; - - /** Management pool size. */ - private int mgmtPoolSize; - - /** IGFS pool size. */ - private int igfsPoolSize; - - /** Peer-to-peer pool size. */ - private int p2pPoolSz; - - /** Rebalance thread pool size. */ - private int rebalanceThreadPoolSize; - - /** REST requests pool size. */ - private int restPoolSz; - - /** Async Callback pool size. */ - private int cbPoolSize; - - /** Data stream pool size. */ - private int dataStreamerPoolSize; - - /** Query pool size. */ - private int qryPoolSize; - - /** Use striped pool for internal requests processing when possible */ - private int stripedPoolSize; - - /** Service pool size. */ - private int svcPoolSize; - - /** Utility cache pool size. */ - private int utilityCachePoolSize; - - /** Client connector configuration pool size. */ - private int cliConnCfgPoolSize; - - /** List of executor configurations. */ - private List executors; - - /** - * Default constructor. - */ - public VisorExecutorServiceConfiguration() { - // No-op. - } - - /** - * Create data transfer object for node executors configuration properties. - * - * @param c Grid configuration. - */ - public VisorExecutorServiceConfiguration(IgniteConfiguration c) { - pubPoolSize = c.getPublicThreadPoolSize(); - sysPoolSz = c.getSystemThreadPoolSize(); - mgmtPoolSize = c.getManagementThreadPoolSize(); - p2pPoolSz = c.getPeerClassLoadingThreadPoolSize(); - rebalanceThreadPoolSize = c.getRebalanceThreadPoolSize(); - - ConnectorConfiguration cc = c.getConnectorConfiguration(); - - if (cc != null) - restPoolSz = cc.getThreadPoolSize(); - - cbPoolSize = c.getAsyncCallbackPoolSize(); - dataStreamerPoolSize = c.getDataStreamerThreadPoolSize(); - qryPoolSize = c.getQueryThreadPoolSize(); - stripedPoolSize = c.getStripedPoolSize(); - svcPoolSize = c.getServiceThreadPoolSize(); - utilityCachePoolSize = c.getUtilityCacheThreadPoolSize(); - - ClientConnectorConfiguration scc = c.getClientConnectorConfiguration(); - - if (scc != null) - cliConnCfgPoolSize = scc.getThreadPoolSize(); - - executors = VisorExecutorConfiguration.list(c.getExecutorConfiguration()); - } - - /** - * @return Public pool size. - */ - public int getPublicThreadPoolSize() { - return pubPoolSize; - } - - /** - * @return System pool size. - */ - public int getSystemThreadPoolSize() { - return sysPoolSz; - } - - /** - * @return Management pool size. - */ - public int getManagementThreadPoolSize() { - return mgmtPoolSize; - } - - /** - * @return IGFS pool size. - */ - public int getIgfsThreadPoolSize() { - return igfsPoolSize; - } - - /** - * @return Peer-to-peer pool size. - */ - public int getPeerClassLoadingThreadPoolSize() { - return p2pPoolSz; - } - - /** - * @return Rebalance thread pool size. - */ - public int getRebalanceThreadPoolSize() { - return rebalanceThreadPoolSize; - } - - /** - * @return REST requests pool size. - */ - public int getRestThreadPoolSize() { - return restPoolSz; - } - - /** - * @return Thread pool size to be used for processing of asynchronous callbacks. - */ - public int getCallbackPoolSize() { - return cbPoolSize; - } - - /** - * @return Thread pool size to be used for data stream messages. - */ - public int getDataStreamerPoolSize() { - return dataStreamerPoolSize; - } - - /** - * @return Thread pool size to be used in grid for query messages. - */ - public int getQueryThreadPoolSize() { - return qryPoolSize; - } - - /** - * @return The number of threads (stripes) to be used for requests processing. - */ - public int getStripedPoolSize() { - return stripedPoolSize; - } - - /** - * @return Thread pool size to be used in grid to process service proxy invocations. - */ - public int getServiceThreadPoolSize() { - return svcPoolSize; - } - - /** - * @return Thread pool size to be used in grid for utility cache messages. - */ - public int getUtilityCacheThreadPoolSize() { - return utilityCachePoolSize; - } - - /** - * @return Thread pool that is in charge of processing ODBC tasks. - */ - public int getClientConnectorConfigurationThreadPoolSize() { - return cliConnCfgPoolSize; - } - - /** - * @return List of executor configurations. - */ - public List getExecutors() { - return executors; - } - - /** {@inheritDoc} */ - @Override protected void writeExternalData(ObjectOutput out) throws IOException { - out.writeInt(pubPoolSize); - out.writeInt(sysPoolSz); - out.writeInt(mgmtPoolSize); - out.writeInt(igfsPoolSize); - out.writeInt(p2pPoolSz); - out.writeInt(rebalanceThreadPoolSize); - out.writeInt(restPoolSz); - out.writeInt(cbPoolSize); - out.writeInt(dataStreamerPoolSize); - out.writeInt(qryPoolSize); - out.writeInt(stripedPoolSize); - out.writeInt(svcPoolSize); - out.writeInt(utilityCachePoolSize); - out.writeInt(cliConnCfgPoolSize); - U.writeCollection(out, executors); - } - - /** {@inheritDoc} */ - @Override protected void readExternalData(byte protoVer, ObjectInput in) throws IOException, ClassNotFoundException { - pubPoolSize = in.readInt(); - sysPoolSz = in.readInt(); - mgmtPoolSize = in.readInt(); - igfsPoolSize = in.readInt(); - p2pPoolSz = in.readInt(); - rebalanceThreadPoolSize = in.readInt(); - restPoolSz = in.readInt(); - cbPoolSize = in.readInt(); - dataStreamerPoolSize = in.readInt(); - qryPoolSize = in.readInt(); - stripedPoolSize = in.readInt(); - svcPoolSize = in.readInt(); - utilityCachePoolSize = in.readInt(); - cliConnCfgPoolSize = in.readInt(); - executors = U.readList(in); - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorExecutorServiceConfiguration.class, this); - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorGridConfiguration.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorGridConfiguration.java deleted file mode 100644 index 17997aa57345d..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorGridConfiguration.java +++ /dev/null @@ -1,470 +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.node; - -import java.io.IOException; -import java.io.ObjectInput; -import java.io.ObjectOutput; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Properties; -import org.apache.ignite.IgniteSystemProperties; -import org.apache.ignite.configuration.BinaryConfiguration; -import org.apache.ignite.configuration.ClientConnectorConfiguration; -import org.apache.ignite.configuration.DataStorageConfiguration; -import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.internal.IgniteEx; -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 static org.apache.ignite.internal.visor.util.VisorTaskUtils.compactArray; -import static org.apache.ignite.internal.visor.util.VisorTaskUtils.compactClass; - -/** - * Data transfer object for node configuration data. - */ -public class VisorGridConfiguration extends VisorDataTransferObject { - /** */ - private static final long serialVersionUID = 0L; - - /** Basic. */ - private VisorBasicConfiguration basic; - - /** Metrics. */ - private VisorMetricsConfiguration metrics; - - /** SPIs. */ - private VisorSpisConfiguration spis; - - /** P2P. */ - private VisorPeerToPeerConfiguration p2p; - - /** Lifecycle. */ - private VisorLifecycleConfiguration lifecycle; - - /** Executors service configuration. */ - private VisorExecutorServiceConfiguration execSvc; - - /** Segmentation. */ - private VisorSegmentationConfiguration seg; - - /** Include properties. */ - private String inclProps; - - /** Include events types. */ - private int[] inclEvtTypes; - - /** REST configuration. */ - private VisorRestConfiguration rest; - - /** User attributes. */ - private Map userAttrs; - - /** IGFSs. */ - private List igfss; - - /** Environment. */ - private Map env; - - /** System properties. */ - private Properties sysProps; - - /** Configuration of atomic data structures. */ - private VisorAtomicConfiguration atomic; - - /** Transactions configuration. */ - private VisorTransactionConfiguration txCfg; - - /** Memory configuration. */ - private VisorMemoryConfiguration memCfg; - - /** Persistence configuration. */ - private VisorPersistentStoreConfiguration psCfg; - - /** Cache store session listeners. */ - private String storeSesLsnrs; - - /** Warmup closure. Will be invoked before actual grid start. */ - private String warmupClos; - - /** Binary configuration. */ - private VisorBinaryConfiguration binaryCfg; - - /** List of cache key configurations. */ - private List cacheKeyCfgs; - - /** Hadoop configuration. */ - private VisorHadoopConfiguration hadoopCfg; - - /** SQL connector configuration. */ - private VisorSqlConnectorConfiguration sqlConnCfg; - - /** List of service configurations. */ - private List srvcCfgs; - - /** Configuration of data storage. */ - private VisorDataStorageConfiguration dataStorage; - - /** Client connector configuration */ - private VisorClientConnectorConfiguration clnConnCfg; - - /** MVCC configuration. */ - private VisorMvccConfiguration mvccCfg; - - /** - * Default constructor. - */ - public VisorGridConfiguration() { - // No-op. - } - - /** - * Create data transfer object with node configuration data. - * - * @param ignite Grid. - */ - public VisorGridConfiguration(IgniteEx ignite) { - assert ignite != null; - - IgniteConfiguration c = ignite.configuration(); - - basic = new VisorBasicConfiguration(ignite, c); - metrics = new VisorMetricsConfiguration(c); - spis = new VisorSpisConfiguration(c); - p2p = new VisorPeerToPeerConfiguration(c); - lifecycle = new VisorLifecycleConfiguration(c); - execSvc = new VisorExecutorServiceConfiguration(c); - seg = new VisorSegmentationConfiguration(c); - inclProps = compactArray(c.getIncludeProperties()); - inclEvtTypes = c.getIncludeEventTypes(); - rest = new VisorRestConfiguration(c); - userAttrs = c.getUserAttributes(); - env = new HashMap<>(System.getenv()); - sysProps = IgniteSystemProperties.snapshot(); - atomic = new VisorAtomicConfiguration(c.getAtomicConfiguration()); - txCfg = new VisorTransactionConfiguration(c.getTransactionConfiguration()); - - if (c.getDataStorageConfiguration() != null) - memCfg = null; - - if (c.getDataStorageConfiguration() != null) - psCfg = null; - - storeSesLsnrs = compactArray(c.getCacheStoreSessionListenerFactories()); - warmupClos = compactClass(c.getWarmupClosure()); - - BinaryConfiguration bc = c.getBinaryConfiguration(); - - if (bc != null) - binaryCfg = new VisorBinaryConfiguration(bc); - - cacheKeyCfgs = VisorCacheKeyConfiguration.list(c.getCacheKeyConfiguration()); - - ClientConnectorConfiguration ccc = c.getClientConnectorConfiguration(); - - if (ccc != null) - clnConnCfg = new VisorClientConnectorConfiguration(ccc); - - srvcCfgs = VisorServiceConfiguration.list(c.getServiceConfiguration()); - - DataStorageConfiguration dsCfg = c.getDataStorageConfiguration(); - - if (dsCfg != null) - dataStorage = new VisorDataStorageConfiguration(dsCfg); - - mvccCfg = new VisorMvccConfiguration(c); - } - - /** - * @return Basic. - */ - public VisorBasicConfiguration getBasic() { - return basic; - } - - /** - * @return Metrics. - */ - public VisorMetricsConfiguration getMetrics() { - return metrics; - } - - /** - * @return SPIs. - */ - public VisorSpisConfiguration getSpis() { - return spis; - } - - /** - * @return P2P. - */ - public VisorPeerToPeerConfiguration getP2p() { - return p2p; - } - - /** - * @return Lifecycle. - */ - public VisorLifecycleConfiguration getLifecycle() { - return lifecycle; - } - - /** - * @return Executors service configuration. - */ - public VisorExecutorServiceConfiguration getExecutorService() { - return execSvc; - } - - /** - * @return Segmentation. - */ - public VisorSegmentationConfiguration getSegmentation() { - return seg; - } - - /** - * @return Include properties. - */ - public String getIncludeProperties() { - return inclProps; - } - - /** - * @return Include events types. - */ - public int[] getIncludeEventTypes() { - return inclEvtTypes; - } - - /** - * @return Rest. - */ - public VisorRestConfiguration getRest() { - return rest; - } - - /** - * @return User attributes. - */ - public Map getUserAttributes() { - return userAttrs; - } - - /** - * @return Igfss. - */ - public List getIgfss() { - return igfss; - } - - /** - * @return Environment. - */ - public Map getEnv() { - return env; - } - - /** - * @return System properties. - */ - public Properties getSystemProperties() { - return sysProps; - } - - /** - * @return Configuration of atomic data structures. - */ - public VisorAtomicConfiguration getAtomic() { - return atomic; - } - - /** - * @return Transactions configuration. - */ - public VisorTransactionConfiguration getTransaction() { - return txCfg; - } - - /** - * @return Memory configuration. - */ - public VisorMemoryConfiguration getMemoryConfiguration() { - return memCfg; - } - - /** - * @return Persistent store configuration. - */ - public VisorPersistentStoreConfiguration getPersistentStoreConfiguration() { - return psCfg; - } - - /** - * @return Cache store session listener factories. - */ - public String getCacheStoreSessionListenerFactories() { - return storeSesLsnrs; - } - - /** - * @return Warmup closure to execute. - */ - public String getWarmupClosure() { - return warmupClos; - } - - /** - * @return Binary configuration. - */ - public VisorBinaryConfiguration getBinaryConfiguration() { - return binaryCfg; - } - - /** - * @return List of cache key configurations. - */ - public List getCacheKeyConfigurations() { - return cacheKeyCfgs; - } - - /** - * @return Hadoop configuration. - */ - public VisorHadoopConfiguration getHadoopConfiguration() { - return hadoopCfg; - } - - /** - * @return SQL connector configuration. - */ - public VisorSqlConnectorConfiguration getSqlConnectorConfiguration() { - return sqlConnCfg; - } - - /** - * @return Client connector configuration. - */ - public VisorClientConnectorConfiguration getClientConnectorConfiguration() { - return clnConnCfg; - } - - /** - * @return List of service configurations - */ - public List getServiceConfigurations() { - return srvcCfgs; - } - - /** - * @return Configuration of data storage. - */ - public VisorDataStorageConfiguration getDataStorageConfiguration() { - return dataStorage; - } - - /** - * @return MVCC configuration. - */ - public VisorMvccConfiguration getMvccConfiguration() { - return mvccCfg; - } - - /** {@inheritDoc} */ - @Override public byte getProtocolVersion() { - return V5; - } - - /** {@inheritDoc} */ - @Override protected void writeExternalData(ObjectOutput out) throws IOException { - out.writeObject(basic); - out.writeObject(metrics); - out.writeObject(spis); - out.writeObject(p2p); - out.writeObject(lifecycle); - out.writeObject(execSvc); - out.writeObject(seg); - U.writeString(out, inclProps); - out.writeObject(inclEvtTypes); - out.writeObject(rest); - U.writeMap(out, userAttrs); - U.writeCollection(out, null); - U.writeMap(out, env); - out.writeObject(sysProps); - out.writeObject(atomic); - out.writeObject(txCfg); - out.writeObject(memCfg); - out.writeObject(psCfg); - U.writeString(out, storeSesLsnrs); - U.writeString(out, warmupClos); - out.writeObject(binaryCfg); - U.writeCollection(out, cacheKeyCfgs); - out.writeObject(null); - out.writeObject(sqlConnCfg); - U.writeCollection(out, srvcCfgs); - out.writeObject(dataStorage); - out.writeObject(clnConnCfg); - out.writeObject(mvccCfg); - } - - /** {@inheritDoc} */ - @Override protected void readExternalData(byte protoVer, ObjectInput in) throws IOException, ClassNotFoundException { - basic = (VisorBasicConfiguration)in.readObject(); - metrics = (VisorMetricsConfiguration)in.readObject(); - spis = (VisorSpisConfiguration)in.readObject(); - p2p = (VisorPeerToPeerConfiguration)in.readObject(); - lifecycle = (VisorLifecycleConfiguration)in.readObject(); - execSvc = (VisorExecutorServiceConfiguration)in.readObject(); - seg = (VisorSegmentationConfiguration)in.readObject(); - inclProps = U.readString(in); - inclEvtTypes = (int[])in.readObject(); - rest = (VisorRestConfiguration)in.readObject(); - userAttrs = U.readMap(in); - igfss = U.readList(in); - env = U.readMap(in); - sysProps = (Properties)in.readObject(); - atomic = (VisorAtomicConfiguration)in.readObject(); - txCfg = (VisorTransactionConfiguration)in.readObject(); - memCfg = (VisorMemoryConfiguration)in.readObject(); - psCfg = (VisorPersistentStoreConfiguration)in.readObject(); - storeSesLsnrs = U.readString(in); - warmupClos = U.readString(in); - binaryCfg = (VisorBinaryConfiguration)in.readObject(); - cacheKeyCfgs = U.readList(in); - hadoopCfg = (VisorHadoopConfiguration)in.readObject(); - sqlConnCfg = (VisorSqlConnectorConfiguration)in.readObject(); - srvcCfgs = U.readList(in); - - if (protoVer > V1) - dataStorage = (VisorDataStorageConfiguration)in.readObject(); - - if (protoVer > V2) - clnConnCfg = (VisorClientConnectorConfiguration)in.readObject(); - - if (protoVer > V3) - mvccCfg = (VisorMvccConfiguration)in.readObject(); - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorGridConfiguration.class, this); - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorHadoopConfiguration.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorHadoopConfiguration.java deleted file mode 100644 index 4d4a97863a413..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorHadoopConfiguration.java +++ /dev/null @@ -1,127 +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.node; - -import java.io.IOException; -import java.io.ObjectInput; -import java.io.ObjectOutput; -import java.util.List; -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; - -/** - * Data transfer object for configuration of hadoop data structures. - */ -public class VisorHadoopConfiguration extends VisorDataTransferObject { - /** */ - private static final long serialVersionUID = 0L; - - /** Map reduce planner. */ - private String planner; - - /** */ - private boolean extExecution; - - /** Finished job info TTL. */ - private long finishedJobInfoTtl; - - /** */ - private int maxParallelTasks; - - /** */ - private int maxTaskQueueSize; - - /** Library names. */ - private List libNames; - - /** - * Default constructor. - */ - public VisorHadoopConfiguration() { - // No-op. - } - - /** - * @return Max number of local tasks that may be executed in parallel. - */ - public int getMaxParallelTasks() { - return maxParallelTasks; - } - - /** - * @return Max task queue size. - */ - public int getMaxTaskQueueSize() { - return maxTaskQueueSize; - } - - /** - * @return Finished job info time-to-live. - */ - public long getFinishedJobInfoTtl() { - return finishedJobInfoTtl; - } - - /** - * @return {@code True} if external execution. - */ - public boolean isExternalExecution() { - return extExecution; - } - - /** - * @return Map-reduce planner. - */ - public String getMapReducePlanner() { - return planner; - } - - /** - * @return Native library names. - */ - @Nullable public List getNativeLibraryNames() { - return libNames; - } - - /** {@inheritDoc} */ - @Override protected void writeExternalData(ObjectOutput out) throws IOException { - U.writeString(out, planner); - out.writeBoolean(extExecution); - out.writeLong(finishedJobInfoTtl); - out.writeInt(maxParallelTasks); - out.writeInt(maxTaskQueueSize); - U.writeCollection(out, libNames); - } - - /** {@inheritDoc} */ - @Override protected void readExternalData(byte protoVer, ObjectInput in) throws IOException, ClassNotFoundException { - planner = U.readString(in); - extExecution = in.readBoolean(); - finishedJobInfoTtl = in.readLong(); - maxParallelTasks = in.readInt(); - maxTaskQueueSize = in.readInt(); - libNames = U.readList(in); - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorHadoopConfiguration.class, this); - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorIgfsConfiguration.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorIgfsConfiguration.java deleted file mode 100644 index 7da280b14f8e6..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorIgfsConfiguration.java +++ /dev/null @@ -1,320 +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.node; - -import java.io.IOException; -import java.io.ObjectInput; -import java.io.ObjectOutput; -import java.util.Map; -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.internal.visor.igfs.VisorIgfsMode; -import org.jetbrains.annotations.Nullable; - -/** - * Data transfer object for IGFS configuration properties. - */ -public class VisorIgfsConfiguration extends VisorDataTransferObject { - /** */ - private static final long serialVersionUID = 0L; - - /** IGFS instance name. */ - private String name; - - /** Cache name to store IGFS meta information. */ - private String metaCacheName; - - /** Cache name to store IGFS data. */ - private String dataCacheName; - - /** File's data block size. */ - private int blockSize; - - /** Number of pre-fetched blocks if specific file's chunk is requested. */ - private int prefetchBlocks; - - /** Read/write buffer size for IGFS stream operations in bytes. */ - private int streamBufSize; - - /** Number of file blocks buffered on local node before sending batch to remote node. */ - private int perNodeBatchSize; - - /** Number of batches that can be concurrently sent to remote node. */ - private int perNodeParallelBatchCnt; - - /** IGFS instance mode. */ - private VisorIgfsMode dfltMode; - - /** Map of paths to IGFS modes. */ - private Map pathModes; - - /** Maximum range length. */ - private long maxTaskRangeLen; - - /** Fragmentizer concurrent files. */ - private int fragmentizerConcurrentFiles; - - /** Fragmentizer enabled flag. */ - private boolean fragmentizerEnabled; - - /** Fragmentizer throttling block length. */ - private long fragmentizerThrottlingBlockLen; - - /** Fragmentizer throttling delay. */ - private long fragmentizerThrottlingDelay; - - /** IPC endpoint config (in JSON format) to publish IGFS over. */ - private String ipcEndpointCfg; - - /** IPC endpoint enabled flag. */ - private boolean ipcEndpointEnabled; - - /** Management port. */ - private int mgmtPort; - - /** Amount of sequential block reads before prefetch is triggered. */ - private int seqReadsBeforePrefetch; - - /** Metadata co-location flag. */ - private boolean colocateMeta; - - /** Relaxed consistency flag. */ - private boolean relaxedConsistency; - - /** Update file length on flush flag. */ - private boolean updateFileLenOnFlush; - - /** - * Default constructor. - */ - public VisorIgfsConfiguration() { - // No-op. - } - - /** - * @return IGFS instance name. - */ - @Nullable public String getName() { - return name; - } - - /** - * @return Cache name to store IGFS meta information. - */ - @Nullable public String getMetaCacheName() { - return metaCacheName; - } - - /** - * @return Cache name to store IGFS data. - */ - @Nullable public String getDataCacheName() { - return dataCacheName; - } - - /** - * @return File's data block size. - */ - public int getBlockSize() { - return blockSize; - } - - /** - * @return Number of pre-fetched blocks if specific file's chunk is requested. - */ - public int getPrefetchBlocks() { - return prefetchBlocks; - } - - /** - * @return Read/write buffer size for IGFS stream operations in bytes. - */ - public int getStreamBufferSize() { - return streamBufSize; - } - - /** - * @return Number of file blocks buffered on local node before sending batch to remote node. - */ - public int getPerNodeBatchSize() { - return perNodeBatchSize; - } - - /** - * @return Number of batches that can be concurrently sent to remote node. - */ - public int getPerNodeParallelBatchCount() { - return perNodeParallelBatchCnt; - } - - /** - * @return IGFS instance mode. - */ - public VisorIgfsMode getDefaultMode() { - return dfltMode; - } - - /** - * @return Map of paths to IGFS modes. - */ - @Nullable public Map getPathModes() { - return pathModes; - } - - /** - * @return Maximum range length. - */ - public long getMaxTaskRangeLength() { - return maxTaskRangeLen; - } - - /** - * @return Fragmentizer concurrent files. - */ - public int getFragmentizerConcurrentFiles() { - return fragmentizerConcurrentFiles; - } - - /** - * @return Fragmentizer enabled flag. - */ - public boolean isFragmentizerEnabled() { - return fragmentizerEnabled; - } - - /** - * @return Fragmentizer throttling block length. - */ - public long getFragmentizerThrottlingBlockLength() { - return fragmentizerThrottlingBlockLen; - } - - /** - * @return Fragmentizer throttling delay. - */ - public long getFragmentizerThrottlingDelay() { - return fragmentizerThrottlingDelay; - } - - /** - * @return IPC endpoint config to publish IGFS over. - */ - @Nullable public String getIpcEndpointConfiguration() { - return ipcEndpointCfg; - } - - /** - * @return IPC endpoint enabled flag. - */ - public boolean isIpcEndpointEnabled() { - return ipcEndpointEnabled; - } - - /** - * @return Management port. - */ - public int getManagementPort() { - return mgmtPort; - } - - /** - * @return Amount of sequential block reads before prefetch is triggered. - */ - public int getSequenceReadsBeforePrefetch() { - return seqReadsBeforePrefetch; - } - - /** - * @return {@code True} if metadata co-location is enabled. - */ - public boolean isColocateMetadata() { - return colocateMeta; - } - - /** - * @return {@code True} if relaxed consistency is enabled. - */ - public boolean isRelaxedConsistency() { - return relaxedConsistency; - } - - /** - * @return Whether to update file length on flush. - */ - public boolean isUpdateFileLengthOnFlush() { - return updateFileLenOnFlush; - } - - /** {@inheritDoc} */ - @Override protected void writeExternalData(ObjectOutput out) throws IOException { - U.writeString(out, name); - U.writeString(out, metaCacheName); - U.writeString(out, dataCacheName); - out.writeInt(blockSize); - out.writeInt(prefetchBlocks); - out.writeInt(streamBufSize); - out.writeInt(perNodeBatchSize); - out.writeInt(perNodeParallelBatchCnt); - U.writeEnum(out, dfltMode); - U.writeMap(out, pathModes); - out.writeLong(maxTaskRangeLen); - out.writeInt(fragmentizerConcurrentFiles); - out.writeBoolean(fragmentizerEnabled); - out.writeLong(fragmentizerThrottlingBlockLen); - out.writeLong(fragmentizerThrottlingDelay); - U.writeString(out, ipcEndpointCfg); - out.writeBoolean(ipcEndpointEnabled); - out.writeInt(mgmtPort); - out.writeInt(seqReadsBeforePrefetch); - out.writeBoolean(colocateMeta); - out.writeBoolean(relaxedConsistency); - out.writeBoolean(updateFileLenOnFlush); - } - - /** {@inheritDoc} */ - @Override protected void readExternalData(byte protoVer, ObjectInput in) throws IOException, ClassNotFoundException { - name = U.readString(in); - metaCacheName = U.readString(in); - dataCacheName = U.readString(in); - blockSize = in.readInt(); - prefetchBlocks = in.readInt(); - streamBufSize = in.readInt(); - perNodeBatchSize = in.readInt(); - perNodeParallelBatchCnt = in.readInt(); - dfltMode = VisorIgfsMode.fromOrdinal(in.readByte()); - pathModes = U.readMap(in); - maxTaskRangeLen = in.readLong(); - fragmentizerConcurrentFiles = in.readInt(); - fragmentizerEnabled = in.readBoolean(); - fragmentizerThrottlingBlockLen = in.readLong(); - fragmentizerThrottlingDelay = in.readLong(); - ipcEndpointCfg = U.readString(in); - ipcEndpointEnabled = in.readBoolean(); - mgmtPort = in.readInt(); - seqReadsBeforePrefetch = in.readInt(); - colocateMeta = in.readBoolean(); - relaxedConsistency = in.readBoolean(); - updateFileLenOnFlush = in.readBoolean(); - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorIgfsConfiguration.class, this); - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorLifecycleConfiguration.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorLifecycleConfiguration.java deleted file mode 100644 index 6aa3c6947c2c6..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorLifecycleConfiguration.java +++ /dev/null @@ -1,78 +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.node; - -import java.io.IOException; -import java.io.ObjectInput; -import java.io.ObjectOutput; -import org.apache.ignite.configuration.IgniteConfiguration; -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.compactArray; - -/** - * Data transfer object for node lifecycle configuration properties. - */ -public class VisorLifecycleConfiguration extends VisorDataTransferObject { - /** */ - private static final long serialVersionUID = 0L; - - /** Lifecycle beans. */ - private String beans; - - /** - * Default constructor. - */ - public VisorLifecycleConfiguration() { - // No-op. - } - - /** - * Create data transfer object for node lifecycle configuration properties. - * - * @param c Grid configuration. - */ - public VisorLifecycleConfiguration(IgniteConfiguration c) { - beans = compactArray(c.getLifecycleBeans()); - } - - /** - * @return Lifecycle beans. - */ - @Nullable public String getBeans() { - return beans; - } - - /** {@inheritDoc} */ - @Override protected void writeExternalData(ObjectOutput out) throws IOException { - U.writeString(out, beans); - } - - /** {@inheritDoc} */ - @Override protected void readExternalData(byte protoVer, ObjectInput in) throws IOException, ClassNotFoundException { - beans = U.readString(in); - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorLifecycleConfiguration.class, this); - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorMemoryConfiguration.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorMemoryConfiguration.java deleted file mode 100644 index 18835a24e28b2..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorMemoryConfiguration.java +++ /dev/null @@ -1,167 +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.node; - -import java.io.IOException; -import java.io.ObjectInput; -import java.io.ObjectOutput; -import java.util.ArrayList; -import java.util.List; -import org.apache.ignite.configuration.DataRegionConfiguration; -import org.apache.ignite.configuration.DataStorageConfiguration; -import org.apache.ignite.internal.util.typedef.F; -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 memory configuration. - */ -public class VisorMemoryConfiguration extends VisorDataTransferObject { - /** */ - private static final long serialVersionUID = 0L; - - /** Size of a memory chunk reserved for system cache initially. */ - private long sysCacheInitSize; - - /** Size of memory for system cache. */ - private long sysCacheMaxSize; - - /** Page size. */ - private int pageSize; - - /** Concurrency level. */ - private int concLvl; - - /** Name of DataRegion to be used as default. */ - private String dfltMemPlcName; - - /** Size of memory (in bytes) to use for default DataRegion. */ - private long dfltMemPlcSize; - - /** Memory policies. */ - private List memPlcs; - - /** - * Default constructor. - */ - public VisorMemoryConfiguration() { - // No-op. - } - - /** - * Create data transfer object. - * - * @param memCfg Memory configuration. - */ - public VisorMemoryConfiguration(DataStorageConfiguration memCfg) { - assert memCfg != null; - - sysCacheInitSize = memCfg.getSystemDataRegionConfiguration().getInitialSize(); - sysCacheMaxSize = memCfg.getSystemDataRegionConfiguration().getMaxSize(); - pageSize = memCfg.getPageSize(); - concLvl = memCfg.getConcurrencyLevel(); -// dfltMemPlcName = memCfg.getDefaultDataRegionName(); - //dfltMemPlcSize = memCfg.getDefaultDataRegionSize(); - - DataRegionConfiguration[] plcs = memCfg.getDataRegionConfigurations(); - - if (!F.isEmpty(plcs)) { - memPlcs = new ArrayList<>(plcs.length); - - for (DataRegionConfiguration plc : plcs) - memPlcs.add(new VisorMemoryPolicyConfiguration(plc)); - } - } - - /** - * @return Concurrency level. - */ - public int getConcurrencyLevel() { - return concLvl; - } - - /** - * @return Initial size of a memory region reserved for system cache. - */ - public long getSystemCacheInitialSize() { - return sysCacheInitSize; - } - - /** - * @return Maximum memory region size reserved for system cache. - */ - public long getSystemCacheMaxSize() { - return sysCacheMaxSize; - } - - /** - * @return Page size. - */ - public int getPageSize() { - return pageSize; - } - - /** - * @return Name of DataRegion to be used as default. - */ - public String getDefaultMemoryPolicyName() { - return dfltMemPlcName; - } - - /** - * @return Default memory policy size. - */ - public long getDefaultMemoryPolicySize() { - return dfltMemPlcSize; - } - - /** - * @return Collection of DataRegionConfiguration objects. - */ - public List getMemoryPolicies() { - return memPlcs; - } - - /** {@inheritDoc} */ - @Override protected void writeExternalData(ObjectOutput out) throws IOException { - out.writeLong(sysCacheInitSize); - out.writeLong(sysCacheMaxSize); - out.writeInt(pageSize); - out.writeInt(concLvl); - U.writeString(out, dfltMemPlcName); - out.writeLong(dfltMemPlcSize); - U.writeCollection(out, memPlcs); - } - - /** {@inheritDoc} */ - @Override protected void readExternalData(byte protoVer, ObjectInput in) throws IOException, ClassNotFoundException { - sysCacheInitSize = in.readLong(); - sysCacheMaxSize = in.readLong(); - pageSize = in.readInt(); - concLvl = in.readInt(); - dfltMemPlcName = U.readString(in); - dfltMemPlcSize = in.readLong(); - memPlcs = U.readList(in); - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorMemoryConfiguration.class, this); - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorMemoryPolicyConfiguration.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorMemoryPolicyConfiguration.java deleted file mode 100644 index 92159a811db69..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorMemoryPolicyConfiguration.java +++ /dev/null @@ -1,159 +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.node; - -import java.io.IOException; -import java.io.ObjectInput; -import java.io.ObjectOutput; -import org.apache.ignite.configuration.DataPageEvictionMode; -import org.apache.ignite.configuration.DataRegionConfiguration; -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 memory configuration. - */ -public class VisorMemoryPolicyConfiguration extends VisorDataTransferObject { - /** */ - private static final long serialVersionUID = 0L; - - /** Unique name of DataRegion. */ - private String name; - - /** Maximum memory region size defined by this memory policy. */ - private long maxSize; - - /** Initial memory region size defined by this memory policy. */ - private long initSize; - - /** Path for memory mapped file. */ - private String swapFilePath; - - /** An algorithm for memory pages eviction. */ - private DataPageEvictionMode pageEvictionMode; - - /** - * A threshold for memory pages eviction initiation. For instance, if the threshold is 0.9 it means that the page - * memory will start the eviction only after 90% memory region (defined by this policy) is occupied. - */ - private double evictionThreshold; - - /** Minimum number of empty pages in reuse lists. */ - private int emptyPagesPoolSize; - - /** - * Default constructor. - */ - public VisorMemoryPolicyConfiguration() { - // No-op. - } - - /** - * Constructor. - * - * @param plc Memory policy configuration. - */ - public VisorMemoryPolicyConfiguration(DataRegionConfiguration plc) { - assert plc != null; - - name = plc.getName(); - maxSize = plc.getMaxSize(); - initSize = plc.getInitialSize(); - swapFilePath = plc.getSwapPath(); - pageEvictionMode = plc.getPageEvictionMode(); - evictionThreshold = plc.getEvictionThreshold(); - emptyPagesPoolSize = plc.getEmptyPagesPoolSize(); - } - - /** - * Unique name of DataRegion. - */ - public String getName() { - return name; - } - - /** - * Maximum memory region size defined by this memory policy. - */ - public long getMaxSize() { - return maxSize; - } - - /** - * Initial memory region size defined by this memory policy. - */ - public long getInitialSize() { - return initSize; - } - - /** - * @return Path for memory mapped file. - */ - public String getSwapFilePath() { - return swapFilePath; - } - - /** - * @return Memory pages eviction algorithm. {@link DataPageEvictionMode#DISABLED} used by default. - */ - public DataPageEvictionMode getPageEvictionMode() { - return pageEvictionMode; - } - - /** - * @return Memory pages eviction threshold. - */ - public double getEvictionThreshold() { - return evictionThreshold; - } - - /** - * @return Minimum number of empty pages in reuse list. - */ - public int getEmptyPagesPoolSize() { - return emptyPagesPoolSize; - } - - /** {@inheritDoc} */ - @Override protected void writeExternalData(ObjectOutput out) throws IOException { - U.writeString(out, name); - out.writeLong(initSize); - out.writeLong(maxSize); - U.writeString(out, swapFilePath); - U.writeEnum(out, pageEvictionMode); - out.writeDouble(evictionThreshold); - out.writeInt(emptyPagesPoolSize); - } - - /** {@inheritDoc} */ - @Override protected void readExternalData(byte protoVer, ObjectInput in) throws IOException, ClassNotFoundException { - name = U.readString(in); - initSize = in.readLong(); - maxSize = in.readLong(); - swapFilePath = U.readString(in); - pageEvictionMode = DataPageEvictionMode.fromOrdinal(in.readByte()); - evictionThreshold = in.readDouble(); - emptyPagesPoolSize = in.readInt(); - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorMemoryPolicyConfiguration.class, this); - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorMetricsConfiguration.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorMetricsConfiguration.java deleted file mode 100644 index 4ce7b6ce61e0b..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorMetricsConfiguration.java +++ /dev/null @@ -1,100 +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.node; - -import java.io.IOException; -import java.io.ObjectInput; -import java.io.ObjectOutput; -import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.internal.util.typedef.internal.S; -import org.apache.ignite.internal.visor.VisorDataTransferObject; - -/** - * Data transfer object for node metrics configuration properties. - */ -public class VisorMetricsConfiguration extends VisorDataTransferObject { - /** */ - private static final long serialVersionUID = 0L; - - /** Metrics expired time. */ - private long expTime; - - /** Number of node metrics stored in memory. */ - private int histSize; - - /** Frequency of metrics log printout. */ - private long logFreq; - - /** - * Default constructor. - */ - public VisorMetricsConfiguration() { - // No-op. - } - - /** - * Create transfer object for node metrics configuration properties. - * - * @param c Grid configuration. - */ - public VisorMetricsConfiguration(IgniteConfiguration c) { - expTime = c.getMetricsExpireTime(); - histSize = c.getMetricsHistorySize(); - logFreq = c.getMetricsLogFrequency(); - } - - /** - * @return Metrics expired time. - */ - public long getExpireTime() { - return expTime; - } - - /** - * @return Number of node metrics stored in memory. - */ - public int getHistorySize() { - return histSize; - } - - /** - * @return Frequency of metrics log printout. - */ - public long getLoggerFrequency() { - return logFreq; - } - - /** {@inheritDoc} */ - @Override protected void writeExternalData(ObjectOutput out) throws IOException { - out.writeLong(expTime); - out.writeInt(histSize); - out.writeLong(logFreq); - } - - /** {@inheritDoc} */ - @Override protected void readExternalData(byte protoVer, ObjectInput in) throws IOException, ClassNotFoundException { - expTime = in.readLong(); - histSize = in.readInt(); - logFreq = in.readLong(); - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorMetricsConfiguration.class, this); - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorMvccConfiguration.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorMvccConfiguration.java deleted file mode 100644 index 1bcaa21507818..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorMvccConfiguration.java +++ /dev/null @@ -1,94 +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.node; - -import java.io.IOException; -import java.io.ObjectInput; -import java.io.ObjectOutput; -import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.internal.util.typedef.internal.S; -import org.apache.ignite.internal.visor.VisorDataTransferObject; - -/** - * Data transfer object for data store configuration. - */ -public class VisorMvccConfiguration extends VisorDataTransferObject { - /** */ - private static final long serialVersionUID = 0L; - - /** Number of MVCC vacuum cleanup threads. */ - private int mvccVacuumThreadCnt; - - /** Time interval between vacuum runs */ - private long mvccVacuumFreq; - - /** - * Default constructor. - */ - public VisorMvccConfiguration() { - // No-op. - } - - /** - * Constructor. - * - * @param cfg Ignite configuration. - */ - public VisorMvccConfiguration(IgniteConfiguration cfg) { - assert cfg != null; - - mvccVacuumThreadCnt = cfg.getMvccVacuumThreadCount(); - mvccVacuumFreq = cfg.getMvccVacuumFrequency(); - } - - /** - * @return Number of MVCC vacuum threads. - */ - public int getMvccVacuumThreadCount() { - return mvccVacuumThreadCnt; - } - - /** - * @return Time interval between MVCC vacuum runs in milliseconds. - */ - public long getMvccVacuumFrequency() { - return mvccVacuumFreq; - } - - /** {@inheritDoc} */ - @Override public byte getProtocolVersion() { - return V1; - } - - /** {@inheritDoc} */ - @Override protected void writeExternalData(ObjectOutput out) throws IOException { - out.writeInt(mvccVacuumThreadCnt); - out.writeLong(mvccVacuumFreq); - } - - /** {@inheritDoc} */ - @Override protected void readExternalData(byte protoVer, ObjectInput in) throws IOException, ClassNotFoundException { - mvccVacuumThreadCnt = in.readInt(); - mvccVacuumFreq = in.readLong(); - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorMvccConfiguration.class, this); - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorNodeBaselineStatus.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorNodeBaselineStatus.java deleted file mode 100644 index a273ca9364a12..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorNodeBaselineStatus.java +++ /dev/null @@ -1,47 +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.node; - -import org.jetbrains.annotations.Nullable; - -/** - * Node baseline status. - */ -public enum VisorNodeBaselineStatus { - /** */ - NODE_IN_BASELINE, - - /** */ - NODE_NOT_IN_BASELINE, - - /** */ - BASELINE_NOT_AVAILABLE; - - /** Enumerated values. */ - private static final VisorNodeBaselineStatus[] VALS = values(); - - /** - * Efficiently gets enumerated value from its ordinal. - * - * @param ord Ordinal value. - * @return Enumerated value or {@code null} if ordinal out of range. - */ - @Nullable public static VisorNodeBaselineStatus fromOrdinal(int ord) { - return ord >= 0 && ord < VALS.length ? VALS[ord] : null; - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorNodeConfigurationCollectorJob.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorNodeConfigurationCollectorJob.java deleted file mode 100644 index 35b7ad3aaa62c..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorNodeConfigurationCollectorJob.java +++ /dev/null @@ -1,47 +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.node; - -import org.apache.ignite.internal.util.typedef.internal.S; -import org.apache.ignite.internal.visor.VisorJob; - -/** - * Grid configuration data collect job. - */ -public class VisorNodeConfigurationCollectorJob extends VisorJob { - /** */ - private static final long serialVersionUID = 0L; - - /** - * @param arg Formal job argument. - * @param debug Debug flag. - */ - public VisorNodeConfigurationCollectorJob(Void arg, boolean debug) { - super(arg, debug); - } - - /** {@inheritDoc} */ - @Override protected VisorGridConfiguration run(Void arg) { - return new VisorGridConfiguration(ignite); - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorNodeConfigurationCollectorJob.class, this); - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorNodeConfigurationCollectorTask.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorNodeConfigurationCollectorTask.java deleted file mode 100644 index 10e77f4caaffc..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorNodeConfigurationCollectorTask.java +++ /dev/null @@ -1,35 +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.node; - -import org.apache.ignite.internal.processors.task.GridInternal; -import org.apache.ignite.internal.visor.VisorOneNodeTask; - -/** - * Grid configuration data collect task. - */ -@GridInternal -public class VisorNodeConfigurationCollectorTask extends VisorOneNodeTask { - /** */ - private static final long serialVersionUID = 0L; - - /** {@inheritDoc} */ - @Override protected VisorNodeConfigurationCollectorJob job(Void arg) { - return new VisorNodeConfigurationCollectorJob(arg, debug); - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorNodeDataCollectorJob.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorNodeDataCollectorJob.java deleted file mode 100644 index 2d2a6674f6c1d..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorNodeDataCollectorJob.java +++ /dev/null @@ -1,308 +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.node; - -import java.util.List; -import java.util.Set; -import java.util.concurrent.ConcurrentMap; -import org.apache.ignite.DataRegionMetrics; -import org.apache.ignite.cache.CacheMetrics; -import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.internal.processors.cache.CacheGroupContext; -import org.apache.ignite.internal.processors.cache.GridCacheAdapter; -import org.apache.ignite.internal.processors.cache.GridCacheContext; -import org.apache.ignite.internal.processors.cache.GridCachePartitionExchangeManager; -import org.apache.ignite.internal.processors.cache.GridCacheProcessor; -import org.apache.ignite.internal.util.typedef.F; -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.cache.VisorCache; -import org.apache.ignite.internal.visor.cache.VisorMemoryMetrics; -import org.apache.ignite.internal.visor.compute.VisorComputeMonitoringHolder; -import org.apache.ignite.internal.visor.util.VisorExceptionWrapper; - -import static org.apache.ignite.internal.processors.cache.GridCacheUtils.isSystemCache; -import static org.apache.ignite.internal.visor.compute.VisorComputeMonitoringHolder.COMPUTE_MONITORING_HOLDER_KEY; -import static org.apache.ignite.internal.visor.util.VisorTaskUtils.EVT_MAPPER; -import static org.apache.ignite.internal.visor.util.VisorTaskUtils.MINIMAL_REBALANCE; -import static org.apache.ignite.internal.visor.util.VisorTaskUtils.NOTHING_TO_REBALANCE; -import static org.apache.ignite.internal.visor.util.VisorTaskUtils.REBALANCE_COMPLETE; -import static org.apache.ignite.internal.visor.util.VisorTaskUtils.REBALANCE_NOT_AVAILABLE; -import static org.apache.ignite.internal.visor.util.VisorTaskUtils.VISOR_TASK_EVTS; -import static org.apache.ignite.internal.visor.util.VisorTaskUtils.checkExplicitTaskMonitoring; -import static org.apache.ignite.internal.visor.util.VisorTaskUtils.collectEvents; -import static org.apache.ignite.internal.visor.util.VisorTaskUtils.isProxyCache; -import static org.apache.ignite.internal.visor.util.VisorTaskUtils.isRestartingCache; -import static org.apache.ignite.internal.visor.util.VisorTaskUtils.log; - -/** - * Job that collects data from node. - */ -public class VisorNodeDataCollectorJob extends VisorJob { - /** */ - private static final long serialVersionUID = 0L; - - /** - * Create job with given argument. - * - * @param arg Job argument. - * @param debug Debug flag. - */ - public VisorNodeDataCollectorJob(VisorNodeDataCollectorTaskArg arg, boolean debug) { - super(arg, debug); - } - - /** - * Collect events. - * - * @param res Job result. - * @param evtOrderKey Unique key to take last order key from node local map. - * @param evtThrottleCntrKey Unique key to take throttle count from node local map. - * @param all If {@code true} then collect all events otherwise collect only non task events. - */ - protected void events0(VisorNodeDataCollectorJobResult res, String evtOrderKey, String evtThrottleCntrKey, - final boolean all) { - res.getEvents().addAll(collectEvents(ignite, evtOrderKey, evtThrottleCntrKey, all, EVT_MAPPER)); - } - - /** - * Collect events. - * - * @param res Job result. - * @param arg Task argument. - */ - protected void events(VisorNodeDataCollectorJobResult res, VisorNodeDataCollectorTaskArg arg) { - try { - // Visor events explicitly enabled in configuration. - if (checkExplicitTaskMonitoring(ignite)) - res.setTaskMonitoringEnabled(true); - else { - // Get current task monitoring state. - res.setTaskMonitoringEnabled(arg.isTaskMonitoringEnabled()); - - if (arg.isTaskMonitoringEnabled()) { - ConcurrentMap storage = ignite.cluster().nodeLocalMap(); - - VisorComputeMonitoringHolder holder = storage.get(COMPUTE_MONITORING_HOLDER_KEY); - - if (holder == null) { - VisorComputeMonitoringHolder holderNew = new VisorComputeMonitoringHolder(); - - VisorComputeMonitoringHolder holderOld = storage.putIfAbsent(COMPUTE_MONITORING_HOLDER_KEY, holderNew); - - holder = holderOld == null ? holderNew : holderOld; - } - - // Enable task monitoring for new node in grid. - holder.startCollect(ignite, arg.getEventsOrderKey()); - - // Update current state after change (it may not changed in some cases). - res.setTaskMonitoringEnabled(ignite.allEventsUserRecordable(VISOR_TASK_EVTS)); - } - } - - events0(res, arg.getEventsOrderKey(), arg.getEventsThrottleCounterKey(), arg.isTaskMonitoringEnabled()); - } - catch (Exception e) { - res.setEventsEx(new VisorExceptionWrapper(e)); - } - } - - /** - * Collect memory metrics. - * - * @param res Job result. - */ - protected void memoryMetrics(VisorNodeDataCollectorJobResult res) { - try { - List memoryMetrics = res.getMemoryMetrics(); - - // TODO: Should be really fixed in IGNITE-7111. - if (ignite.cluster().active()) { - for (DataRegionMetrics m : ignite.dataRegionMetrics()) - memoryMetrics.add(new VisorMemoryMetrics(m)); - } - } - catch (Exception e) { - res.setMemoryMetricsEx(new VisorExceptionWrapper(e)); - } - } - - /** - * Collect caches. - * - * @param res Job result. - * @param arg Task argument. - */ - protected void caches(VisorNodeDataCollectorJobResult res, VisorNodeDataCollectorTaskArg arg) { - try { - IgniteConfiguration cfg = ignite.configuration(); - - GridCacheProcessor cacheProc = ignite.context().cache(); - - Set cacheGrps = arg.getCacheGroups(); - - boolean all = F.isEmpty(cacheGrps); - - int partitions = 0; - double total = 0; - double ready = 0; - - List resCaches = res.getCaches(); - - boolean rebalanceInProgress = false; - - for (CacheGroupContext grp : cacheProc.cacheGroups()) { - boolean first = true; - - for (GridCacheContext cache : grp.caches()) { - long start0 = U.currentTimeMillis(); - - String cacheName = cache.name(); - - try { - if (isProxyCache(ignite, cacheName) || isRestartingCache(ignite, cacheName)) - continue; - - GridCacheAdapter ca = cacheProc.internalCache(cacheName); - - if (ca == null || !ca.context().started()) - continue; - - if (first) { - CacheMetrics cm = ca.localMetrics(); - - partitions += cm.getTotalPartitionsCount(); - - long keysTotal = cm.getEstimatedRebalancingKeys(); - long keysReady = cm.getRebalancedKeys(); - - if (keysReady >= keysTotal) - keysReady = Math.max(keysTotal - 1, 0); - - total += keysTotal; - ready += keysReady; - - if (!rebalanceInProgress && cm.getRebalancingPartitionsCount() > 0) - rebalanceInProgress = true; - - first = false; - } - - boolean addToRes = arg.getSystemCaches() || !(isSystemCache(cacheName)); - - if (addToRes && (all || cacheGrps.contains(ca.configuration().getGroupName()))) - resCaches.add(new VisorCache(ignite, ca, arg.isCollectCacheMetrics())); - } - catch (IllegalStateException | IllegalArgumentException e) { - if (debug && ignite.log() != null) - ignite.log().error("Ignored cache: " + cacheName, e); - } - finally { - if (debug) - log(ignite.log(), "Collected cache: " + cacheName, getClass(), start0); - } - } - } - - if (partitions == 0) - res.setRebalance(NOTHING_TO_REBALANCE); - else if (total == 0 && rebalanceInProgress) - res.setRebalance(MINIMAL_REBALANCE); - else - res.setRebalance(total > 0 && rebalanceInProgress - ? Math.max(ready / total, MINIMAL_REBALANCE) - : REBALANCE_COMPLETE); - } - catch (Exception e) { - res.setRebalance(REBALANCE_NOT_AVAILABLE); - res.setCachesEx(new VisorExceptionWrapper(e)); - } - } - - /** - * Collect persistence metrics. - * - * @param res Job result. - */ - protected void persistenceMetrics(VisorNodeDataCollectorJobResult res) { - try { - res.setPersistenceMetrics(new VisorPersistenceMetrics(ignite.context().metric())); - } - catch (Exception e) { - res.setPersistenceMetricsEx(new VisorExceptionWrapper(e)); - } - } - - /** {@inheritDoc} */ - @Override protected VisorNodeDataCollectorJobResult run(VisorNodeDataCollectorTaskArg arg) { - return run(new VisorNodeDataCollectorJobResult(), arg); - } - - /** - * Execution logic of concrete job. - * - * @param res Result response. - * @param arg Job argument. - * @return Job result. - */ - protected VisorNodeDataCollectorJobResult run(VisorNodeDataCollectorJobResult res, - VisorNodeDataCollectorTaskArg arg) { - res.setGridName(ignite.name()); - - GridCachePartitionExchangeManager exchange = ignite.context().cache().context().exchange(); - - res.setReadyAffinityVersion(new VisorAffinityTopologyVersion(exchange.readyAffinityVersion())); - res.setHasPendingExchange(exchange.hasPendingExchange()); - - res.setTopologyVersion(ignite.cluster().topologyVersion()); - - long start0 = U.currentTimeMillis(); - - events(res, arg); - - if (debug) - start0 = log(ignite.log(), "Collected events", getClass(), start0); - - memoryMetrics(res); - - if (debug) - start0 = log(ignite.log(), "Collected memory metrics", getClass(), start0); - - if (ignite.cluster().active()) - caches(res, arg); - - if (debug) - start0 = log(ignite.log(), "Collected caches", getClass(), start0); - - persistenceMetrics(res); - - if (debug) - log(ignite.log(), "Collected persistence metrics", getClass(), start0); - - res.setErrorCount(ignite.context().exceptionRegistry().errorCount()); - - return res; - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorNodeDataCollectorJob.class, this); - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorNodeDataCollectorJobResult.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorNodeDataCollectorJobResult.java deleted file mode 100644 index e3501572a65fc..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorNodeDataCollectorJobResult.java +++ /dev/null @@ -1,375 +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.node; - -import java.io.IOException; -import java.io.ObjectInput; -import java.io.ObjectOutput; -import java.util.ArrayList; -import java.util.List; -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.internal.visor.cache.VisorCache; -import org.apache.ignite.internal.visor.cache.VisorMemoryMetrics; -import org.apache.ignite.internal.visor.event.VisorGridEvent; -import org.apache.ignite.internal.visor.igfs.VisorIgfs; -import org.apache.ignite.internal.visor.igfs.VisorIgfsEndpoint; -import org.apache.ignite.internal.visor.util.VisorExceptionWrapper; - -/** - * Data collector job result. - */ -public class VisorNodeDataCollectorJobResult extends VisorDataTransferObject { - /** */ - private static final long serialVersionUID = 0L; - - /** Grid name. */ - private String gridName; - - /** Node topology version. */ - private long topVer; - - /** Task monitoring state collected from node. */ - private boolean taskMonitoringEnabled; - - /** Node events. */ - private List evts = new ArrayList<>(); - - /** Exception while collecting node events. */ - private VisorExceptionWrapper evtsEx; - - /** Node data region metrics. */ - private List memoryMetrics = new ArrayList<>(); - - /** Exception while collecting memory metrics. */ - private VisorExceptionWrapper memoryMetricsEx; - - /** Node caches. */ - private List caches = new ArrayList<>(); - - /** Exception while collecting node caches. */ - private VisorExceptionWrapper cachesEx; - - /** Node IGFSs. */ - private List igfss = new ArrayList<>(); - - /** All IGFS endpoints collected from nodes. */ - private List igfsEndpoints = new ArrayList<>(); - - /** Exception while collecting node IGFSs. */ - private VisorExceptionWrapper igfssEx; - - /** Errors count. */ - private long errCnt; - - /** Topology version of latest completed partition exchange. */ - private VisorAffinityTopologyVersion readyTopVer; - - /** Whether pending exchange future exists. */ - private boolean hasPendingExchange; - - /** Persistence metrics. */ - private VisorPersistenceMetrics persistenceMetrics; - - /** Exception while collecting persistence metrics. */ - private VisorExceptionWrapper persistenceMetricsEx; - - /** Rebalance percent. */ - private double rebalance; - - /** - * Default constructor. - */ - public VisorNodeDataCollectorJobResult() { - // No-op. - } - - /** - * @return Grid name. - */ - public String getGridName() { - return gridName; - } - - /** - * @param gridName New grid name value. - */ - public void setGridName(String gridName) { - this.gridName = gridName; - } - - /** - * @return Current topology version. - */ - public long getTopologyVersion() { - return topVer; - } - - /** - * @param topVer New topology version value. - */ - public void setTopologyVersion(long topVer) { - this.topVer = topVer; - } - - /** - * @return Current task monitoring state. - */ - public boolean isTaskMonitoringEnabled() { - return taskMonitoringEnabled; - } - - /** - * @param taskMonitoringEnabled New value of task monitoring state. - */ - public void setTaskMonitoringEnabled(boolean taskMonitoringEnabled) { - this.taskMonitoringEnabled = taskMonitoringEnabled; - } - - /** - * @return Collection of collected events. - */ - public List getEvents() { - return evts; - } - - /** - * @return Exception caught during collecting events. - */ - public VisorExceptionWrapper getEventsEx() { - return evtsEx; - } - - /** - * @param evtsEx Exception caught during collecting events. - */ - public void setEventsEx(VisorExceptionWrapper evtsEx) { - this.evtsEx = evtsEx; - } - - /** - * @return Collected data region metrics. - */ - public List getMemoryMetrics() { - return memoryMetrics; - } - - /** - * @return Exception caught during collecting memory metrics. - */ - public VisorExceptionWrapper getMemoryMetricsEx() { - return memoryMetricsEx; - } - - /** - * @param memoryMetricsEx Exception caught during collecting memory metrics. - */ - public void setMemoryMetricsEx(VisorExceptionWrapper memoryMetricsEx) { - this.memoryMetricsEx = memoryMetricsEx; - } - - /** - * @return Collected cache metrics. - */ - public List getCaches() { - return caches; - } - - /** - * @return Exception caught during collecting caches metrics. - */ - public VisorExceptionWrapper getCachesEx() { - return cachesEx; - } - - /** - * @param cachesEx Exception caught during collecting caches metrics. - */ - public void setCachesEx(VisorExceptionWrapper cachesEx) { - this.cachesEx = cachesEx; - } - - /** - * @return Collected IGFSs metrics. - */ - public List getIgfss() { - return igfss; - } - - /** - * @return Collected IGFSs endpoints. - */ - public List getIgfsEndpoints() { - return igfsEndpoints; - } - - /** - * @return Exception caught during collecting IGFSs metrics. - */ - public VisorExceptionWrapper getIgfssEx() { - return igfssEx; - } - - /** - * @param igfssEx Exception caught during collecting IGFSs metrics. - */ - public void setIgfssEx(VisorExceptionWrapper igfssEx) { - this.igfssEx = igfssEx; - } - - /** - * @return Errors count. - */ - public long getErrorCount() { - return errCnt; - } - - /** - * @param errCnt Errors count. - */ - public void setErrorCount(long errCnt) { - this.errCnt = errCnt; - } - - /** - * @return Topology version of latest completed partition exchange. - */ - public VisorAffinityTopologyVersion getReadyAffinityVersion() { - return readyTopVer; - } - - /** - * @param readyTopVer Topology version of latest completed partition exchange. - */ - public void setReadyAffinityVersion(VisorAffinityTopologyVersion readyTopVer) { - this.readyTopVer = readyTopVer; - } - - /** - * @return Whether pending exchange future exists. - */ - public boolean isHasPendingExchange() { - return hasPendingExchange; - } - - /** - * @param hasPendingExchange Whether pending exchange future exists. - */ - public void setHasPendingExchange(boolean hasPendingExchange) { - this.hasPendingExchange = hasPendingExchange; - } - - /** - * Get persistence metrics. - */ - public VisorPersistenceMetrics getPersistenceMetrics() { - return persistenceMetrics; - } - - /** - * Set persistence metrics. - * - * @param persistenceMetrics Persistence metrics. - */ - public void setPersistenceMetrics(VisorPersistenceMetrics persistenceMetrics) { - this.persistenceMetrics = persistenceMetrics; - } - - /** - * @return Exception caught during collecting persistence metrics. - */ - public VisorExceptionWrapper getPersistenceMetricsEx() { - return persistenceMetricsEx; - } - - /** - * @param persistenceMetricsEx Exception caught during collecting persistence metrics. - */ - public void setPersistenceMetricsEx(VisorExceptionWrapper persistenceMetricsEx) { - this.persistenceMetricsEx = persistenceMetricsEx; - } - - /** - * @return Rebalance progress. - */ - public double getRebalance() { - return rebalance; - } - - /** - * @param rebalance Rebalance progress. - */ - public void setRebalance(double rebalance) { - this.rebalance = rebalance; - } - - /** {@inheritDoc} */ - @Override public byte getProtocolVersion() { - return V2; - } - - /** {@inheritDoc} */ - @Override protected void writeExternalData(ObjectOutput out) throws IOException { - U.writeString(out, gridName); - out.writeLong(topVer); - out.writeBoolean(taskMonitoringEnabled); - U.writeCollection(out, evts); - out.writeObject(evtsEx); - U.writeCollection(out, memoryMetrics); - out.writeObject(memoryMetricsEx); - U.writeCollection(out, caches); - out.writeObject(cachesEx); - U.writeCollection(out, igfss); - U.writeCollection(out, igfsEndpoints); - out.writeObject(igfssEx); - out.writeLong(errCnt); - out.writeObject(readyTopVer); - out.writeBoolean(hasPendingExchange); - out.writeObject(persistenceMetrics); - out.writeObject(persistenceMetricsEx); - out.writeDouble(rebalance); - } - - /** {@inheritDoc} */ - @Override protected void readExternalData(byte protoVer, ObjectInput in) throws IOException, ClassNotFoundException { - gridName = U.readString(in); - topVer = in.readLong(); - taskMonitoringEnabled = in.readBoolean(); - evts = U.readList(in); - evtsEx = (VisorExceptionWrapper)in.readObject(); - memoryMetrics = U.readList(in); - memoryMetricsEx = (VisorExceptionWrapper)in.readObject(); - caches = U.readList(in); - cachesEx = (VisorExceptionWrapper)in.readObject(); - igfss = U.readList(in); - igfsEndpoints = U.readList(in); - igfssEx = (VisorExceptionWrapper)in.readObject(); - errCnt = in.readLong(); - readyTopVer = (VisorAffinityTopologyVersion)in.readObject(); - hasPendingExchange = in.readBoolean(); - persistenceMetrics = (VisorPersistenceMetrics)in.readObject(); - persistenceMetricsEx = (VisorExceptionWrapper)in.readObject(); - rebalance = (protoVer > V1) ? in.readDouble() : -1; - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorNodeDataCollectorJobResult.class, this); - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorNodeDataCollectorTask.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorNodeDataCollectorTask.java deleted file mode 100644 index 067c57ba18033..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorNodeDataCollectorTask.java +++ /dev/null @@ -1,136 +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.node; - -import java.util.List; -import java.util.UUID; -import org.apache.ignite.IgniteException; -import org.apache.ignite.cluster.ClusterGroupEmptyException; -import org.apache.ignite.compute.ComputeJobResult; -import org.apache.ignite.internal.processors.task.GridInternal; -import org.apache.ignite.internal.util.typedef.F; -import org.apache.ignite.internal.visor.VisorMultiNodeTask; -import org.apache.ignite.internal.visor.util.VisorExceptionWrapper; -import org.jetbrains.annotations.Nullable; - -/** - * Collects current Grid state mostly topology and metrics. - */ -@GridInternal -public class VisorNodeDataCollectorTask extends VisorMultiNodeTask { - /** */ - private static final long serialVersionUID = 0L; - - /** {@inheritDoc} */ - @Override protected VisorNodeDataCollectorJob job(VisorNodeDataCollectorTaskArg arg) { - return new VisorNodeDataCollectorJob(arg, debug); - } - - /** {@inheritDoc} */ - @Nullable @Override protected VisorNodeDataCollectorTaskResult reduce0(List results) { - return reduce(new VisorNodeDataCollectorTaskResult(), results); - } - - /** - * @param taskRes Task result. - * @param results Results. - * @return Data collector task result. - */ - protected VisorNodeDataCollectorTaskResult reduce(VisorNodeDataCollectorTaskResult taskRes, - List results) { - for (ComputeJobResult res : results) { - VisorNodeDataCollectorJobResult jobRes = res.getData(); - - if (jobRes != null) { - UUID nid = res.getNode().id(); - - IgniteException unhandledEx = res.getException(); - - if (unhandledEx == null) - reduceJobResult(taskRes, jobRes, nid); - else { - // Ignore nodes that left topology. - if (!(unhandledEx instanceof ClusterGroupEmptyException)) - taskRes.getUnhandledEx().put(nid, new VisorExceptionWrapper(unhandledEx)); - } - } - } - - taskRes.setActive(ignite.cluster().active()); - - return taskRes; - } - - /** - * Reduce job result. - * - * @param taskRes Task result. - * @param jobRes Job result. - * @param nid Node ID. - */ - protected void reduceJobResult(VisorNodeDataCollectorTaskResult taskRes, - VisorNodeDataCollectorJobResult jobRes, UUID nid) { - taskRes.getGridNames().put(nid, jobRes.getGridName()); - - taskRes.getTopologyVersions().put(nid, jobRes.getTopologyVersion()); - - taskRes.getTaskMonitoringEnabled().put(nid, jobRes.isTaskMonitoringEnabled()); - - taskRes.getErrorCounts().put(nid, jobRes.getErrorCount()); - - if (!F.isEmpty(jobRes.getEvents())) - taskRes.getEvents().addAll(jobRes.getEvents()); - - if (jobRes.getEventsEx() != null) - taskRes.getEventsEx().put(nid, jobRes.getEventsEx()); - - if (!F.isEmpty(jobRes.getMemoryMetrics())) - taskRes.getMemoryMetrics().put(nid, jobRes.getMemoryMetrics()); - - if (jobRes.getMemoryMetricsEx() != null) - taskRes.getMemoryMetricsEx().put(nid, jobRes.getMemoryMetricsEx()); - - if (!F.isEmpty(jobRes.getCaches())) - taskRes.getCaches().put(nid, jobRes.getCaches()); - - if (jobRes.getCachesEx() != null) - taskRes.getCachesEx().put(nid, jobRes.getCachesEx()); - - if (!F.isEmpty(jobRes.getIgfss())) - taskRes.getIgfss().put(nid, jobRes.getIgfss()); - - if (!F.isEmpty(jobRes.getIgfsEndpoints())) - taskRes.getIgfsEndpoints().put(nid, jobRes.getIgfsEndpoints()); - - if (jobRes.getIgfssEx() != null) - taskRes.getIgfssEx().put(nid, jobRes.getIgfssEx()); - - if (jobRes.getPersistenceMetrics() != null) - taskRes.getPersistenceMetrics().put(nid, jobRes.getPersistenceMetrics()); - - if (jobRes.getPersistenceMetricsEx() != null) - taskRes.getPersistenceMetricsEx().put(nid, jobRes.getPersistenceMetricsEx()); - - taskRes.getReadyAffinityVersions().put(nid, jobRes.getReadyAffinityVersion()); - - taskRes.getPendingExchanges().put(nid, jobRes.isHasPendingExchange()); - - taskRes.getRebalance().put(nid, jobRes.getRebalance()); - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorNodeDataCollectorTaskArg.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorNodeDataCollectorTaskArg.java deleted file mode 100644 index 328527e4d135c..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorNodeDataCollectorTaskArg.java +++ /dev/null @@ -1,238 +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.node; - -import java.io.IOException; -import java.io.ObjectInput; -import java.io.ObjectOutput; -import java.util.Set; - -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 collector task arguments. - */ -public class VisorNodeDataCollectorTaskArg extends VisorDataTransferObject { - /** */ - private static final long serialVersionUID = 0L; - - /** Whether task monitoring should be enabled. */ - private boolean taskMonitoringEnabled; - - /** Visor unique key to get last event order from node local storage. */ - private String evtOrderKey; - - /** Visor unique key to get lost events throttle counter from node local storage. */ - private String evtThrottleCntrKey; - - /** If {@code true} then collect information about system caches. */ - private boolean sysCaches; - - /** If {@code false} then cache metrics will not be collected. */ - private boolean collectCacheMetrics; - - /** Optional Set of cache groups, if provided, then caches only from that groups will be collected. */ - private Set cacheGrps; - - /** - * Default constructor. - */ - public VisorNodeDataCollectorTaskArg() { - // No-op. - } - - /** - * Create task arguments with given parameters. - * - * @param taskMonitoringEnabled If {@code true} then Visor should collect information about tasks. - * @param evtOrderKey Event order key, unique for Visor instance. - * @param evtThrottleCntrKey Event throttle counter key, unique for Visor instance. - * @param sysCaches If {@code true} then collect information about system caches. - * @param collectCacheMetrics If {@code false} then cache metrics will not be collected. - * @param cacheGrps Optional Set of cache groups, if provided, then caches only from that groups will be collected. - */ - public VisorNodeDataCollectorTaskArg( - boolean taskMonitoringEnabled, - String evtOrderKey, - String evtThrottleCntrKey, - boolean sysCaches, - boolean collectCacheMetrics, - Set cacheGrps - ) { - this.taskMonitoringEnabled = taskMonitoringEnabled; - this.evtOrderKey = evtOrderKey; - this.evtThrottleCntrKey = evtThrottleCntrKey; - this.sysCaches = sysCaches; - this.collectCacheMetrics = collectCacheMetrics; - this.cacheGrps = cacheGrps; - } - - /** - * Create task arguments with given parameters. - * - * @param taskMonitoringEnabled If {@code true} then Visor should collect information about tasks. - * @param evtOrderKey Event order key, unique for Visor instance. - * @param evtThrottleCntrKey Event throttle counter key, unique for Visor instance. - * @param sysCaches If {@code true} then collect information about system caches. - * @param collectCacheMetrics If {@code false} then cache metrics will not be collected. - */ - public VisorNodeDataCollectorTaskArg( - boolean taskMonitoringEnabled, - String evtOrderKey, - String evtThrottleCntrKey, - boolean sysCaches, - boolean collectCacheMetrics - ) { - this(taskMonitoringEnabled, evtOrderKey, evtThrottleCntrKey, sysCaches, collectCacheMetrics, null); - } - - /** - * Create task arguments with given parameters. - * - * @param taskMonitoringEnabled If {@code true} then Visor should collect information about tasks. - * @param evtOrderKey Event order key, unique for Visor instance. - * @param evtThrottleCntrKey Event throttle counter key, unique for Visor instance. - * @param sysCaches If {@code true} then collect information about system caches. - */ - public VisorNodeDataCollectorTaskArg( - boolean taskMonitoringEnabled, - String evtOrderKey, - String evtThrottleCntrKey, - boolean sysCaches - ) { - this(taskMonitoringEnabled, evtOrderKey, evtThrottleCntrKey, sysCaches, true, null); - } - - /** - * @return {@code true} if Visor should collect information about tasks. - */ - public boolean isTaskMonitoringEnabled() { - return taskMonitoringEnabled; - } - - /** - * @param taskMonitoringEnabled If {@code true} then Visor should collect information about tasks. - */ - public void setTaskMonitoringEnabled(boolean taskMonitoringEnabled) { - this.taskMonitoringEnabled = taskMonitoringEnabled; - } - - /** - * @return Key for store and read last event order number. - */ - public String getEventsOrderKey() { - return evtOrderKey; - } - - /** - * @param evtOrderKey Key for store and read last event order number. - */ - public void setEventsOrderKey(String evtOrderKey) { - this.evtOrderKey = evtOrderKey; - } - - /** - * @return Key for store and read events throttle counter. - */ - public String getEventsThrottleCounterKey() { - return evtThrottleCntrKey; - } - - /** - * @param evtThrottleCntrKey Key for store and read events throttle counter. - */ - public void setEventsThrottleCounterKey(String evtThrottleCntrKey) { - this.evtThrottleCntrKey = evtThrottleCntrKey; - } - - /** - * @return {@code true} if Visor should collect metrics for system caches. - */ - public boolean getSystemCaches() { - return sysCaches; - } - - /** - * @param sysCaches {@code true} if Visor should collect metrics for system caches. - */ - public void setSystemCaches(boolean sysCaches) { - this.sysCaches = sysCaches; - } - - /** - * @return If {@code false} then cache metrics will not be collected. - */ - public boolean isCollectCacheMetrics() { - return collectCacheMetrics; - } - - /** - * @param collectCacheMetrics If {@code false} then cache metrics will not be collected. - */ - public void setCollectCacheMetrics(boolean collectCacheMetrics) { - this.collectCacheMetrics = collectCacheMetrics; - } - - /** - * @return Optional cache group, if provided, then caches only from that group will be collected. - */ - public Set getCacheGroups() { - return cacheGrps; - } - - /** - * @param cacheGrps Optional Set of cache groups, if provided, then caches only from that groups will be collected. - */ - public void setCacheGroups(Set cacheGrps) { - this.cacheGrps = cacheGrps; - } - - /** {@inheritDoc} */ - @Override public byte getProtocolVersion() { - return V3; - } - - /** {@inheritDoc} */ - @Override protected void writeExternalData(ObjectOutput out) throws IOException { - out.writeBoolean(taskMonitoringEnabled); - U.writeString(out, evtOrderKey); - U.writeString(out, evtThrottleCntrKey); - out.writeBoolean(sysCaches); - out.writeBoolean(collectCacheMetrics); - U.writeCollection(out, cacheGrps); - } - - /** {@inheritDoc} */ - @Override protected void readExternalData(byte protoVer, ObjectInput in) throws IOException, ClassNotFoundException { - taskMonitoringEnabled = in.readBoolean(); - evtOrderKey = U.readString(in); - evtThrottleCntrKey = U.readString(in); - sysCaches = in.readBoolean(); - - collectCacheMetrics = protoVer < V2 || in.readBoolean(); - - cacheGrps = protoVer < V3 ? null : U.readSet(in); - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorNodeDataCollectorTaskArg.class, this); - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorNodeDataCollectorTaskResult.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorNodeDataCollectorTaskResult.java deleted file mode 100644 index f8eb8690ce2ea..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorNodeDataCollectorTaskResult.java +++ /dev/null @@ -1,374 +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.node; - -import java.io.IOException; -import java.io.ObjectInput; -import java.io.ObjectOutput; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -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.VisorDataTransferObject; -import org.apache.ignite.internal.visor.cache.VisorCache; -import org.apache.ignite.internal.visor.cache.VisorMemoryMetrics; -import org.apache.ignite.internal.visor.event.VisorGridEvent; -import org.apache.ignite.internal.visor.igfs.VisorIgfs; -import org.apache.ignite.internal.visor.igfs.VisorIgfsEndpoint; -import org.apache.ignite.internal.visor.util.VisorExceptionWrapper; - -/** - * Data collector task result. - */ -public class VisorNodeDataCollectorTaskResult extends VisorDataTransferObject { - /** */ - private static final long serialVersionUID = 0L; - - /** Grid active flag. */ - private boolean active; - - /** Unhandled exceptions from nodes. */ - private Map unhandledEx = new HashMap<>(); - - /** Nodes grid names. */ - private Map gridNames = new HashMap<>(); - - /** Nodes topology versions. */ - private Map topVersions = new HashMap<>(); - - /** All task monitoring state collected from nodes. */ - private Map taskMonitoringEnabled = new HashMap<>(); - - /** Nodes error counts. */ - private Map errCnts = new HashMap<>(); - - /** All events collected from nodes. */ - private List evts = new ArrayList<>(); - - /** Exceptions caught during collecting events from nodes. */ - private Map evtsEx = new HashMap<>(); - - /** All data region metrics collected from nodes. */ - private Map> memoryMetrics = new HashMap<>(); - - /** Exceptions caught during collecting memory metrics from nodes. */ - private Map memoryMetricsEx = new HashMap<>(); - - /** All caches collected from nodes. */ - private Map> caches = new HashMap<>(); - - /** Exceptions caught during collecting caches from nodes. */ - private Map cachesEx = new HashMap<>(); - - /** All IGFS collected from nodes. */ - private Map> igfss = new HashMap<>(); - - /** All IGFS endpoints collected from nodes. */ - private Map> igfsEndpoints = new HashMap<>(); - - /** Exceptions caught during collecting IGFS from nodes. */ - private Map igfssEx = new HashMap<>(); - - /** Topology version of latest completed partition exchange from nodes. */ - private Map readyTopVers = new HashMap<>(); - - /** Whether pending exchange future exists from nodes. */ - private Map pendingExchanges = new HashMap<>(); - - /** All persistence metrics collected from nodes. */ - private Map persistenceMetrics = new HashMap<>(); - - /** Exceptions caught during collecting persistence metrics from nodes. */ - private Map persistenceMetricsEx = new HashMap<>(); - - /** Rebalance state on nodes. */ - private Map rebalance = new HashMap<>(); - - /** - * Default constructor. - */ - public VisorNodeDataCollectorTaskResult() { - // No-op. - } - - /** - * @return {@code true} If no data was collected. - */ - public boolean isEmpty() { - return - gridNames.isEmpty() && - topVersions.isEmpty() && - unhandledEx.isEmpty() && - taskMonitoringEnabled.isEmpty() && - evts.isEmpty() && - evtsEx.isEmpty() && - memoryMetrics.isEmpty() && - memoryMetricsEx.isEmpty() && - caches.isEmpty() && - cachesEx.isEmpty() && - igfss.isEmpty() && - igfsEndpoints.isEmpty() && - igfssEx.isEmpty() && - readyTopVers.isEmpty() && - pendingExchanges.isEmpty() && - persistenceMetrics.isEmpty() && - persistenceMetricsEx.isEmpty() && - rebalance.isEmpty(); - } - - /** - * @return {@code True} if grid is active. - */ - public boolean isActive() { - return active; - } - - /** - * @param active active New value of grid active flag. - */ - public void setActive(boolean active) { - this.active = active; - } - - /** - * @return Unhandled exceptions from nodes. - */ - public Map getUnhandledEx() { - return unhandledEx; - } - - /** - * @return Nodes grid names. - */ - public Map getGridNames() { - return gridNames; - } - - /** - * @return Nodes topology versions. - */ - public Map getTopologyVersions() { - return topVersions; - } - - /** - * @return All task monitoring state collected from nodes. - */ - public Map getTaskMonitoringEnabled() { - return taskMonitoringEnabled; - } - - /** - * @return All events collected from nodes. - */ - public List getEvents() { - return evts; - } - - /** - * @return Exceptions caught during collecting events from nodes. - */ - public Map getEventsEx() { - return evtsEx; - } - - /** - * @return All data region metrics collected from nodes. - */ - public Map> getMemoryMetrics() { - return memoryMetrics; - } - - /** - * @return Exceptions caught during collecting memory metrics from nodes. - */ - public Map getMemoryMetricsEx() { - return memoryMetricsEx; - } - - /** - * @return All caches collected from nodes. - */ - public Map> getCaches() { - return caches; - } - - /** - * @return Exceptions caught during collecting caches from nodes. - */ - public Map getCachesEx() { - return cachesEx; - } - - /** - * @return All IGFS collected from nodes. - */ - public Map> getIgfss() { - return igfss; - } - - /** - * @return All IGFS endpoints collected from nodes. - */ - public Map> getIgfsEndpoints() { - return igfsEndpoints; - } - - /** - * @return Exceptions caught during collecting IGFS from nodes. - */ - public Map getIgfssEx() { - return igfssEx; - } - - /** - * @return Nodes error counts. - */ - public Map getErrorCounts() { - return errCnts; - } - - /** - * @return Topology version of latest completed partition exchange from nodes. - */ - public Map getReadyAffinityVersions() { - return readyTopVers; - } - - /** - * @return Whether pending exchange future exists from nodes. - */ - public Map getPendingExchanges() { - return pendingExchanges; - } - - /** - * All persistence metrics collected from nodes. - */ - public Map getPersistenceMetrics() { - return persistenceMetrics; - } - - /** - * @return Exceptions caught during collecting persistence metrics from nodes. - */ - public Map getPersistenceMetricsEx() { - return persistenceMetricsEx; - } - - /** - * @return Rebalance on nodes. - */ - public Map getRebalance() { - return rebalance; - } - - /** {@inheritDoc} */ - @Override public byte getProtocolVersion() { - return V2; - } - - /** - * Add specified results. - * - * @param res Results to add. - */ - public void add(VisorNodeDataCollectorTaskResult res) { - assert res != null; - - active = active || res.isActive(); - unhandledEx.putAll(res.getUnhandledEx()); - gridNames.putAll(res.getGridNames()); - topVersions.putAll(res.getTopologyVersions()); - taskMonitoringEnabled.putAll(res.getTaskMonitoringEnabled()); - errCnts.putAll(res.getErrorCounts()); - evts.addAll(res.getEvents()); - evtsEx.putAll(res.getEventsEx()); - memoryMetrics.putAll(res.getMemoryMetrics()); - memoryMetricsEx.putAll(res.getMemoryMetricsEx()); - caches.putAll(res.getCaches()); - cachesEx.putAll(res.getCachesEx()); - igfss.putAll(res.getIgfss()); - igfsEndpoints.putAll(res.getIgfsEndpoints()); - igfssEx.putAll(res.getIgfssEx()); - readyTopVers.putAll(res.getReadyAffinityVersions()); - pendingExchanges.putAll(res.getPendingExchanges()); - persistenceMetrics.putAll(res.getPersistenceMetrics()); - persistenceMetricsEx.putAll(res.getPersistenceMetricsEx()); - rebalance.putAll(res.getRebalance()); - } - - /** {@inheritDoc} */ - @Override protected void writeExternalData(ObjectOutput out) throws IOException { - out.writeBoolean(active); - U.writeMap(out, unhandledEx); - U.writeMap(out, gridNames); - U.writeMap(out, topVersions); - U.writeMap(out, taskMonitoringEnabled); - U.writeMap(out, errCnts); - U.writeCollection(out, evts); - U.writeMap(out, evtsEx); - U.writeMap(out, memoryMetrics); - U.writeMap(out, memoryMetricsEx); - U.writeMap(out, caches); - U.writeMap(out, cachesEx); - U.writeMap(out, igfss); - U.writeMap(out, igfsEndpoints); - U.writeMap(out, igfssEx); - U.writeMap(out, readyTopVers); - U.writeMap(out, pendingExchanges); - U.writeMap(out, persistenceMetrics); - U.writeMap(out, persistenceMetricsEx); - U.writeMap(out, rebalance); - } - - /** {@inheritDoc} */ - @Override protected void readExternalData(byte protoVer, ObjectInput in) throws IOException, ClassNotFoundException { - active = in.readBoolean(); - unhandledEx = U.readMap(in); - gridNames = U.readMap(in); - topVersions = U.readMap(in); - taskMonitoringEnabled = U.readMap(in); - errCnts = U.readMap(in); - evts = U.readList(in); - evtsEx = U.readMap(in); - memoryMetrics = U.readMap(in); - memoryMetricsEx = U.readMap(in); - caches = U.readMap(in); - cachesEx = U.readMap(in); - igfss = U.readMap(in); - igfsEndpoints = U.readMap(in); - igfssEx = U.readMap(in); - readyTopVers = U.readMap(in); - pendingExchanges = U.readMap(in); - persistenceMetrics = U.readMap(in); - persistenceMetricsEx = U.readMap(in); - - if (protoVer > V1) - rebalance = U.readMap(in); - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorNodeDataCollectorTaskResult.class, this); - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorNodeEventsCollectorTask.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorNodeEventsCollectorTask.java deleted file mode 100644 index bb6c83ea37285..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorNodeEventsCollectorTask.java +++ /dev/null @@ -1,220 +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.node; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.List; -import java.util.concurrent.ConcurrentMap; -import org.apache.ignite.compute.ComputeJobResult; -import org.apache.ignite.events.DeploymentEvent; -import org.apache.ignite.events.Event; -import org.apache.ignite.events.JobEvent; -import org.apache.ignite.events.TaskEvent; -import org.apache.ignite.internal.processors.task.GridInternal; -import org.apache.ignite.internal.util.typedef.F; -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.internal.visor.event.VisorGridEvent; -import org.apache.ignite.internal.visor.util.VisorEventMapper; -import org.apache.ignite.lang.IgniteClosure; -import org.apache.ignite.lang.IgnitePredicate; -import org.apache.ignite.lang.IgniteUuid; - -import static org.apache.ignite.internal.visor.util.VisorTaskUtils.EVT_MAPPER; - -/** - * Task that runs on specified node and returns events data. - */ -@GridInternal -public class VisorNodeEventsCollectorTask extends VisorMultiNodeTask, Collection> { - /** */ - private static final long serialVersionUID = 0L; - - /** {@inheritDoc} */ - @Override protected VisorNodeEventsCollectorJob job(VisorNodeEventsCollectorTaskArg arg) { - return new VisorNodeEventsCollectorJob(arg, debug); - } - - /** {@inheritDoc} */ - @Override protected Iterable reduce0(List results) { - Collection allEvts = new ArrayList<>(); - - for (ComputeJobResult r : results) { - if (r.getException() == null) - allEvts.addAll((Collection)r.getData()); - } - - return allEvts.isEmpty() ? Collections.emptyList() : allEvts; - } - - /** - * Job for task returns events data. - */ - protected static class VisorNodeEventsCollectorJob extends VisorJob> { - /** */ - private static final long serialVersionUID = 0L; - - /** - * Create job with specified argument. - * - * @param arg Job argument. - * @param debug Debug flag. - */ - protected VisorNodeEventsCollectorJob(VisorNodeEventsCollectorTaskArg arg, boolean debug) { - super(arg, debug); - } - - /** - * Tests whether or not this task has specified substring in its name. - * - * @param taskName Task name to check. - * @param taskClsName Task class name to check. - * @param s Substring to check. - */ - private boolean containsInTaskName(String taskName, String taskClsName, String s) { - assert taskName != null; - assert taskClsName != null; - - if (taskName.equals(taskClsName)) { - int idx = taskName.lastIndexOf('.'); - - return ((idx >= 0) ? taskName.substring(idx + 1) : taskName).toLowerCase().contains(s); - } - - return taskName.toLowerCase().contains(s); - } - - /** - * Filter events containing visor in it's name. - * - * @param e Event - * @param taskName Task name to filter of events. - * @return {@code true} if not contains {@code visor} in task name. - */ - private boolean filterByTaskName(Event e, String taskName) { - String compareTaskName = taskName.toLowerCase(); - - if (e.getClass().equals(TaskEvent.class)) { - TaskEvent te = (TaskEvent)e; - - return containsInTaskName(te.taskName(), te.taskClassName(), compareTaskName); - } - - if (e.getClass().equals(JobEvent.class)) { - JobEvent je = (JobEvent)e; - - return containsInTaskName(je.taskName(), je.taskName(), compareTaskName); - } - - if (e.getClass().equals(DeploymentEvent.class)) { - DeploymentEvent de = (DeploymentEvent)e; - - return de.alias().toLowerCase().contains(compareTaskName); - } - - return true; - } - - /** - * Filter events containing visor in it's name. - * - * @param e Event - * @return {@code true} if not contains {@code visor} in task name. - */ - private boolean filterByTaskSessionId(Event e, IgniteUuid taskSesId) { - if (e.getClass().equals(TaskEvent.class)) { - TaskEvent te = (TaskEvent)e; - - return te.taskSessionId().equals(taskSesId); - } - - if (e.getClass().equals(JobEvent.class)) { - JobEvent je = (JobEvent)e; - - return je.taskSessionId().equals(taskSesId); - } - - return true; - } - - /** - * @return Events mapper. - */ - protected VisorEventMapper eventMapper() { - return EVT_MAPPER; - } - - /** {@inheritDoc} */ - @Override protected Collection run(final VisorNodeEventsCollectorTaskArg arg) { - final long startEvtTime = arg.getTimeArgument() == null ? 0L : System.currentTimeMillis() - arg.getTimeArgument(); - - final ConcurrentMap nl = ignite.cluster().nodeLocalMap(); - - final Long startEvtOrder = arg.getKeyOrder() != null && nl.containsKey(arg.getKeyOrder()) ? - nl.get(arg.getKeyOrder()) : -1L; - - Collection evts = ignite.events().localQuery(new IgnitePredicate() { - /** */ - private static final long serialVersionUID = 0L; - - @Override public boolean apply(Event evt) { - return evt.localOrder() > startEvtOrder && - (arg.getTypeArgument() == null || F.contains(arg.getTypeArgument(), evt.type())) && - (evt.timestamp() >= startEvtTime) && - (arg.getTaskName() == null || filterByTaskName(evt, arg.getTaskName())) && - (arg.getTaskSessionId() == null || filterByTaskSessionId(evt, arg.getTaskSessionId())); - } - }); - - Collection res = new ArrayList<>(evts.size()); - - Long maxOrder = startEvtOrder; - - IgniteClosure mapper = eventMapper(); - - for (Event e : evts) { - maxOrder = Math.max(maxOrder, e.localOrder()); - - VisorGridEvent visorEvt = mapper.apply(e); - - if (visorEvt != null) - res.add(visorEvt); - else - res.add(new VisorGridEvent( - e.type(), e.id(), e.name(), e.node().id(), e.timestamp(), e.message(), e.shortDisplay() - )); - } - - // Update latest order in node local, if not empty. - if (arg.getKeyOrder() != null && !res.isEmpty()) - nl.put(arg.getKeyOrder(), maxOrder); - - return res; - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorNodeEventsCollectorJob.class, this); - } - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorNodeEventsCollectorTaskArg.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorNodeEventsCollectorTaskArg.java deleted file mode 100644 index 06cb34059f25c..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorNodeEventsCollectorTaskArg.java +++ /dev/null @@ -1,163 +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.node; - -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; -import org.apache.ignite.lang.IgniteUuid; -import org.jetbrains.annotations.Nullable; - -import static org.apache.ignite.events.EventType.EVTS_JOB_EXECUTION; -import static org.apache.ignite.events.EventType.EVTS_TASK_EXECUTION; -import static org.apache.ignite.internal.visor.util.VisorTaskUtils.concat; - -/** - * Argument for task returns events data. - */ -public class VisorNodeEventsCollectorTaskArg extends VisorDataTransferObject { - /** */ - private static final long serialVersionUID = 0L; - - /** Node local storage key. */ - private String keyOrder; - - /** Arguments for type filter. */ - private int[] typeArg; - - /** Arguments for time filter. */ - private Long timeArg; - - /** Task or job events with task name contains. */ - private String taskName; - - /** Task or job events with session. */ - private IgniteUuid taskSesId; - - /** - * Default constructor. - */ - public VisorNodeEventsCollectorTaskArg() { - // No-op. - } - - /** - * @param keyOrder Arguments for node local storage key. - * @param typeArg Arguments for type filter. - * @param timeArg Arguments for time filter. - * @param taskName Arguments for task name filter. - * @param taskSesId Arguments for task session filter. - */ - public VisorNodeEventsCollectorTaskArg(@Nullable String keyOrder, @Nullable int[] typeArg, - @Nullable Long timeArg, - @Nullable String taskName, @Nullable IgniteUuid taskSesId) { - this.keyOrder = keyOrder; - this.typeArg = typeArg; - this.timeArg = timeArg; - this.taskName = taskName; - this.taskSesId = taskSesId; - } - - /** - * @param typeArg Arguments for type filter. - * @param timeArg Arguments for time filter. - */ - public static VisorNodeEventsCollectorTaskArg createEventsArg(@Nullable int[] typeArg, @Nullable Long timeArg) { - return new VisorNodeEventsCollectorTaskArg(null, typeArg, timeArg, null, null); - } - - /** - * @param timeArg Arguments for time filter. - * @param taskName Arguments for task name filter. - * @param taskSesId Arguments for task session filter. - */ - public static VisorNodeEventsCollectorTaskArg createTasksArg(@Nullable Long timeArg, @Nullable String taskName, - @Nullable IgniteUuid taskSesId) { - return new VisorNodeEventsCollectorTaskArg(null, concat(EVTS_JOB_EXECUTION, EVTS_TASK_EXECUTION), - timeArg, taskName, taskSesId); - } - - /** - * @param keyOrder Arguments for node local storage key. - * @param typeArg Arguments for type filter. - */ - public static VisorNodeEventsCollectorTaskArg createLogArg(@Nullable String keyOrder, @Nullable int[] typeArg) { - return new VisorNodeEventsCollectorTaskArg(keyOrder, typeArg, null, null, null); - } - - /** - * @return Node local storage key. - */ - @Nullable public String getKeyOrder() { - return keyOrder; - } - - /** - * @return Arguments for type filter. - */ - public int[] getTypeArgument() { - return typeArg; - } - - /** - * @return Arguments for time filter. - */ - public Long getTimeArgument() { - return timeArg; - } - - /** - * @return Task or job events with task name contains. - */ - public String getTaskName() { - return taskName; - } - - /** - * @return Task or job events with session. - */ - public IgniteUuid getTaskSessionId() { - return taskSesId; - } - - /** {@inheritDoc} */ - @Override protected void writeExternalData(ObjectOutput out) throws IOException { - U.writeString(out, keyOrder); - out.writeObject(typeArg); - out.writeObject(timeArg); - U.writeString(out, taskName); - U.writeIgniteUuid(out, taskSesId); - } - - /** {@inheritDoc} */ - @Override protected void readExternalData(byte protoVer, ObjectInput in) throws IOException, ClassNotFoundException { - keyOrder = U.readString(in); - typeArg = (int[])in.readObject(); - timeArg = (Long)in.readObject(); - taskName = U.readString(in); - taskSesId = U.readIgniteUuid(in); - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorNodeEventsCollectorTaskArg.class, this); - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorNodeGcTask.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorNodeGcTask.java deleted file mode 100644 index 1e0ca4717d4f7..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorNodeGcTask.java +++ /dev/null @@ -1,102 +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.node; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.UUID; -import org.apache.ignite.cluster.ClusterMetrics; -import org.apache.ignite.cluster.ClusterNode; -import org.apache.ignite.compute.ComputeJobResult; -import org.apache.ignite.internal.processors.task.GridInternal; -import org.apache.ignite.internal.processors.task.GridVisorManagementTask; -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.jetbrains.annotations.Nullable; - -/** - * Task to run gc on nodes. - */ -@GridInternal -@GridVisorManagementTask -public class VisorNodeGcTask extends VisorMultiNodeTask, VisorNodeGcTaskResult> { - /** */ - private static final long serialVersionUID = 0L; - - /** {@inheritDoc} */ - @Override protected VisorNodeGcJob job(Void arg) { - return new VisorNodeGcJob(arg, debug); - } - - /** {@inheritDoc} */ - @Nullable @Override protected Map reduce0(List results) { - Map total = new HashMap<>(); - - for (ComputeJobResult res : results) { - VisorNodeGcTaskResult jobRes = res.getData(); - - total.put(res.getNode().id(), jobRes); - } - - return total; - } - - /** Job that perform GC on node. */ - private static class VisorNodeGcJob extends VisorJob { - /** */ - private static final long serialVersionUID = 0L; - - /** - * Create job with given argument. - * - * @param arg Formal task argument. - * @param debug Debug flag. - */ - private VisorNodeGcJob(Void arg, boolean debug) { - super(arg, debug); - } - - /** {@inheritDoc} */ - @Override protected VisorNodeGcTaskResult run(Void arg) { - ClusterNode locNode = ignite.localNode(); - - long before = freeHeap(locNode); - - System.gc(); - - return new VisorNodeGcTaskResult(before, freeHeap(locNode)); - } - - /** - * @param node Node. - * @return Current free heap. - */ - private long freeHeap(ClusterNode node) { - final ClusterMetrics m = node.metrics(); - - return m.getHeapMemoryMaximum() - m.getHeapMemoryUsed(); - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorNodeGcJob.class, this); - } - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorNodeGcTaskResult.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorNodeGcTaskResult.java deleted file mode 100644 index eb12ef75b2346..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorNodeGcTaskResult.java +++ /dev/null @@ -1,85 +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.node; - -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.visor.VisorDataTransferObject; - -/** - * Argument for task returns GC execution results. - */ -public class VisorNodeGcTaskResult extends VisorDataTransferObject { - /** */ - private static final long serialVersionUID = 0L; - - /** Size before GC execution. */ - private long sizeBefore; - - /** Size after GC execution. */ - private long sizeAfter; - - /** - * Default constructor. - */ - public VisorNodeGcTaskResult() { - // No-op. - } - - /** - * @param sizeBefore Size before GC execution. - * @param sizeAfter Size after GC execution. - */ - public VisorNodeGcTaskResult(long sizeBefore, long sizeAfter) { - this.sizeBefore = sizeBefore; - this.sizeAfter = sizeAfter; - } - - /** - * @return Size before GC execution. - */ - public Long getSizeBefore() { - return sizeBefore; - } - - /** - * @return Size after GC execution. - */ - public Long getSizeAfter() { - return sizeAfter; - } - - /** {@inheritDoc} */ - @Override protected void writeExternalData(ObjectOutput out) throws IOException { - out.writeLong(sizeBefore); - out.writeLong(sizeAfter); - } - - /** {@inheritDoc} */ - @Override protected void readExternalData(byte protoVer, ObjectInput in) throws IOException, ClassNotFoundException { - sizeBefore = in.readLong(); - sizeAfter = in.readLong(); - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorNodeGcTaskResult.class, this); - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorNodePingTask.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorNodePingTask.java deleted file mode 100644 index 656d12aee3d52..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorNodePingTask.java +++ /dev/null @@ -1,81 +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.node; - -import java.util.List; -import org.apache.ignite.cluster.ClusterTopologyException; -import org.apache.ignite.compute.ComputeJobResult; -import org.apache.ignite.internal.processors.task.GridInternal; -import org.apache.ignite.internal.processors.task.GridVisorManagementTask; -import org.apache.ignite.internal.util.typedef.internal.S; -import org.apache.ignite.internal.visor.VisorJob; -import org.apache.ignite.internal.visor.VisorOneNodeTask; -import org.jetbrains.annotations.Nullable; - -/** - * Ping other node. - */ -@GridInternal -@GridVisorManagementTask -public class VisorNodePingTask extends VisorOneNodeTask { - /** */ - private static final long serialVersionUID = 0L; - - /** {@inheritDoc} */ - @Override protected VisorNodePingJob job(VisorNodePingTaskArg arg) { - return new VisorNodePingJob(arg, debug); - } - - /** {@inheritDoc} */ - @Nullable @Override protected VisorNodePingTaskResult reduce0(List results) { - try { - return super.reduce0(results); - } - catch (ClusterTopologyException ignored) { - return new VisorNodePingTaskResult(false, -1L, -1L); - } - } - - /** - * Job that ping node. - */ - private static class VisorNodePingJob extends VisorJob { - /** */ - private static final long serialVersionUID = 0L; - - /** - * @param arg Node ID to ping. - * @param debug Debug flag. - */ - protected VisorNodePingJob(VisorNodePingTaskArg arg, boolean debug) { - super(arg, debug); - } - - /** {@inheritDoc} */ - @Override protected VisorNodePingTaskResult run(VisorNodePingTaskArg arg) { - long start = System.currentTimeMillis(); - - return new VisorNodePingTaskResult(ignite.cluster().pingNode(arg.getNodeId()), start, System.currentTimeMillis()); - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorNodePingJob.class, this); - } - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorNodePingTaskArg.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorNodePingTaskArg.java deleted file mode 100644 index bd5a8262512d4..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorNodePingTaskArg.java +++ /dev/null @@ -1,73 +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.node; - -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.VisorDataTransferObject; - -/** - * Argument for {@link VisorNodePingTask}. - */ -public class VisorNodePingTaskArg extends VisorDataTransferObject { - /** */ - private static final long serialVersionUID = 0L; - - /** Node ID to ping. */ - private UUID nodeId; - - /** - * Default constructor. - */ - public VisorNodePingTaskArg() { - // No-op. - } - - /** - * @param nodeId Node ID to ping. - */ - public VisorNodePingTaskArg(UUID nodeId) { - this.nodeId = nodeId; - } - - /** - * @return Node ID to ping. - */ - public UUID getNodeId() { - return nodeId; - } - - /** {@inheritDoc} */ - @Override protected void writeExternalData(ObjectOutput out) throws IOException { - U.writeUuid(out, nodeId); - } - - /** {@inheritDoc} */ - @Override protected void readExternalData(byte protoVer, ObjectInput in) throws IOException, ClassNotFoundException { - nodeId = U.readUuid(in); - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorNodePingTaskArg.class, this); - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorNodePingTaskResult.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorNodePingTaskResult.java deleted file mode 100644 index 5328f658dce42..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorNodePingTaskResult.java +++ /dev/null @@ -1,99 +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.node; - -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.visor.VisorDataTransferObject; - -/** - * Result for {@link VisorNodePingTask}. - */ -public class VisorNodePingTaskResult extends VisorDataTransferObject { - /** */ - private static final long serialVersionUID = 0L; - - /** Node alive. */ - private boolean alive; - - /** Ping start time. */ - private long startTime; - - /** Ping finish time. */ - private long finishTime; - - /** - * Default constructor. - */ - public VisorNodePingTaskResult() { - // No-op. - } - - /** - * @param alive Node alive. - * @param startTime Ping start time. - * @param finishTime Ping finish time. - */ - public VisorNodePingTaskResult(boolean alive, long startTime, long finishTime) { - this.alive = alive; - this.startTime = startTime; - this.finishTime = finishTime; - } - - /** - * @return Node alive. - */ - public boolean isAlive() { - return alive; - } - - /** - * @return Ping start time. - */ - public long getStartTime() { - return startTime; - } - - /** - * @return Ping finish time. - */ - public long getFinishTime() { - return finishTime; - } - - /** {@inheritDoc} */ - @Override protected void writeExternalData(ObjectOutput out) throws IOException { - out.writeBoolean(alive); - out.writeLong(startTime); - out.writeLong(finishTime); - } - - /** {@inheritDoc} */ - @Override protected void readExternalData(byte protoVer, ObjectInput in) throws IOException, ClassNotFoundException { - alive = in.readBoolean(); - startTime = in.readLong(); - finishTime = in.readLong(); - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorNodePingTaskResult.class, this); - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorNodeRestartTask.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorNodeRestartTask.java deleted file mode 100644 index 7c5d4b073826c..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorNodeRestartTask.java +++ /dev/null @@ -1,80 +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.node; - -import java.util.List; -import org.apache.ignite.Ignition; -import org.apache.ignite.compute.ComputeJobResult; -import org.apache.ignite.internal.processors.task.GridInternal; -import org.apache.ignite.internal.processors.task.GridVisorManagementTask; -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.jetbrains.annotations.Nullable; - -/** - * Restarts nodes. - */ -@GridInternal -@GridVisorManagementTask -public class VisorNodeRestartTask extends VisorMultiNodeTask { - /** */ - private static final long serialVersionUID = 0L; - - /** {@inheritDoc} */ - @Nullable @Override protected Void reduce0(List results) { - return null; - } - - /** - * Job that restart node. - */ - private static class VisorNodesRestartJob extends VisorJob { - /** */ - private static final long serialVersionUID = 0L; - - /** - * @param arg Formal job argument. - * @param debug Debug flag. - */ - private VisorNodesRestartJob(Void arg, boolean debug) { - super(arg, debug); - } - - /** {@inheritDoc} */ - @Override protected Void run(Void arg) { - new Thread(new Runnable() { - @Override public void run() { - Ignition.restart(true); - } - }, "grid-restarter").start(); - - return null; - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorNodesRestartJob.class, this); - } - } - - /** {@inheritDoc} */ - @Override protected VisorNodesRestartJob job(Void arg) { - return new VisorNodesRestartJob(arg, debug); - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorNodeStopTask.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorNodeStopTask.java deleted file mode 100644 index 702e5826348f7..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorNodeStopTask.java +++ /dev/null @@ -1,80 +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.node; - -import java.util.List; -import org.apache.ignite.Ignition; -import org.apache.ignite.compute.ComputeJobResult; -import org.apache.ignite.internal.processors.task.GridInternal; -import org.apache.ignite.internal.processors.task.GridVisorManagementTask; -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.jetbrains.annotations.Nullable; - -/** - * Stops nodes. - */ -@GridInternal -@GridVisorManagementTask -public class VisorNodeStopTask extends VisorMultiNodeTask { - /** */ - private static final long serialVersionUID = 0L; - - /** {@inheritDoc} */ - @Override protected VisorNodesStopJob job(Void arg) { - return new VisorNodesStopJob(arg, debug); - } - - /** {@inheritDoc} */ - @Nullable @Override protected Void reduce0(List results) { - return null; - } - - /** - * Job that stop node. - */ - private static class VisorNodesStopJob extends VisorJob { - /** */ - private static final long serialVersionUID = 0L; - - /** - * @param arg Formal job argument. - * @param debug Debug flag. - */ - private VisorNodesStopJob(Void arg, boolean debug) { - super(arg, debug); - } - - /** {@inheritDoc} */ - @Override protected Void run(Void arg) { - new Thread(new Runnable() { - @Override public void run() { - Ignition.kill(true); - } - }, "grid-stopper").start(); - - return null; - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorNodesStopJob.class, this); - } - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorNodeSuppressedErrors.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorNodeSuppressedErrors.java deleted file mode 100644 index fa599ec70f4de..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorNodeSuppressedErrors.java +++ /dev/null @@ -1,89 +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.node; - -import java.io.IOException; -import java.io.ObjectInput; -import java.io.ObjectOutput; -import java.util.List; -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; - -/** - * Create data transfer object for node's suppressed errors. - */ -public class VisorNodeSuppressedErrors extends VisorDataTransferObject { - /** */ - private static final long serialVersionUID = 0L; - - /** Order number of last suppressed error. */ - private long order; - - /** List of suppressed errors. */ - private List errors; - - /** - * Default constructor. - */ - public VisorNodeSuppressedErrors() { - // No-op. - } - - /** - * Create data transfer object for node's suppressed errors. - * - * @param order Order number of last suppressed error. - * @param errors List of suppressed errors. - */ - public VisorNodeSuppressedErrors(long order, List errors) { - this.order = order; - this.errors = errors; - } - - /** - * @return Order number of last suppressed error. - */ - public long getOrder() { - return order; - } - - /** - * @return List of suppressed errors. - */ - public List getErrors() { - return errors; - } - - /** {@inheritDoc} */ - @Override protected void writeExternalData(ObjectOutput out) throws IOException { - out.writeLong(order); - U.writeCollection(out, errors); - } - - /** {@inheritDoc} */ - @Override protected void readExternalData(byte protoVer, ObjectInput in) throws IOException, ClassNotFoundException { - order = in.readLong(); - errors = U.readList(in); - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorNodeSuppressedErrors.class, this); - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorNodeSuppressedErrorsTask.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorNodeSuppressedErrorsTask.java deleted file mode 100644 index 263d3e73ddfe9..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorNodeSuppressedErrorsTask.java +++ /dev/null @@ -1,110 +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.node; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.UUID; -import org.apache.ignite.compute.ComputeJobResult; -import org.apache.ignite.internal.processors.task.GridInternal; -import org.apache.ignite.internal.util.IgniteExceptionRegistry; -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.internal.visor.util.VisorExceptionWrapper; -import org.jetbrains.annotations.Nullable; - -/** - * Task to collect last errors on nodes. - */ -@GridInternal -public class VisorNodeSuppressedErrorsTask extends VisorMultiNodeTask, VisorNodeSuppressedErrors> { - /** */ - private static final long serialVersionUID = 0L; - - /** {@inheritDoc} */ - @Override protected VisorNodeSuppressedErrorsJob job(VisorNodeSuppressedErrorsTaskArg arg) { - return new VisorNodeSuppressedErrorsJob(arg, debug); - } - - /** {@inheritDoc} */ - @Nullable @Override protected Map - reduce0(List results) { - Map taskRes = - new HashMap<>(results.size()); - - for (ComputeJobResult res : results) { - VisorNodeSuppressedErrors jobRes = res.getData(); - - taskRes.put(res.getNode().id(), jobRes); - } - - return taskRes; - } - - /** - * Job to collect last errors on nodes. - */ - private static class VisorNodeSuppressedErrorsJob extends VisorJob { - /** */ - private static final long serialVersionUID = 0L; - - /** - * Create job with given argument. - * - * @param arg Map with last error counter. - * @param debug Debug flag. - */ - private VisorNodeSuppressedErrorsJob(VisorNodeSuppressedErrorsTaskArg arg, boolean debug) { - super(arg, debug); - } - - /** {@inheritDoc} */ - @Override protected VisorNodeSuppressedErrors run(VisorNodeSuppressedErrorsTaskArg arg) { - Long lastOrder = arg.getOrders().get(ignite.localNode().id()); - - long order = lastOrder != null ? lastOrder : 0; - - List errors = ignite.context().exceptionRegistry().getErrors(order); - - List wrapped = new ArrayList<>(errors.size()); - - for (IgniteExceptionRegistry.ExceptionInfo error : errors) { - if (error.order() > order) - order = error.order(); - - wrapped.add(new VisorSuppressedError(error.order(), - new VisorExceptionWrapper(error.error()), - error.message(), - error.threadId(), - error.threadName(), - error.time())); - } - - return new VisorNodeSuppressedErrors(order, wrapped); - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorNodeSuppressedErrorsJob.class, this); - } - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorNodeSuppressedErrorsTaskArg.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorNodeSuppressedErrorsTaskArg.java deleted file mode 100644 index 17f7a9c921121..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorNodeSuppressedErrorsTaskArg.java +++ /dev/null @@ -1,74 +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.node; - -import java.io.IOException; -import java.io.ObjectInput; -import java.io.ObjectOutput; -import java.util.Map; -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.VisorDataTransferObject; - -/** - * Arguments for task {@link VisorNodeSuppressedErrorsTask} - */ -public class VisorNodeSuppressedErrorsTaskArg extends VisorDataTransferObject { - /** */ - private static final long serialVersionUID = 0L; - - /** Last laded error orders. */ - private Map orders; - - /** - * Default constructor. - */ - public VisorNodeSuppressedErrorsTaskArg() { - // No-op. - } - - /** - * @param orders Last laded error orders. - */ - public VisorNodeSuppressedErrorsTaskArg(Map orders) { - this.orders = orders; - } - - /** - * @return Last laded error orders. - */ - public Map getOrders() { - return orders; - } - - /** {@inheritDoc} */ - @Override protected void writeExternalData(ObjectOutput out) throws IOException { - U.writeMap(out, orders); - } - - /** {@inheritDoc} */ - @Override protected void readExternalData(byte protoVer, ObjectInput in) throws IOException, ClassNotFoundException { - orders = U.readMap(in); - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorNodeSuppressedErrorsTaskArg.class, this); - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorPeerToPeerConfiguration.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorPeerToPeerConfiguration.java deleted file mode 100644 index ab9e140f23afc..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorPeerToPeerConfiguration.java +++ /dev/null @@ -1,104 +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.node; - -import java.io.IOException; -import java.io.ObjectInput; -import java.io.ObjectOutput; -import java.util.Arrays; -import java.util.List; -import org.apache.ignite.configuration.IgniteConfiguration; -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; - -/** - * Data transfer object for node P2P configuration properties. - */ -public class VisorPeerToPeerConfiguration extends VisorDataTransferObject { - /** */ - private static final long serialVersionUID = 0L; - - /** Whether peer-to-peer class loading is enabled. */ - private boolean p2pEnabled; - - /** Missed resource cache size. */ - private int p2pMissedResCacheSize; - - /** List of packages from the system classpath that need to be loaded from task originating node. */ - private List p2pLocClsPathExcl; - - /** - * Default constructor. - */ - public VisorPeerToPeerConfiguration() { - // No-op. - } - - /** - * Create data transfer object for node P2P configuration properties. - * - * @param c Grid configuration. - */ - public VisorPeerToPeerConfiguration(IgniteConfiguration c) { - p2pEnabled = c.isPeerClassLoadingEnabled(); - p2pMissedResCacheSize = c.getPeerClassLoadingMissedResourcesCacheSize(); - p2pLocClsPathExcl = Arrays.asList(c.getPeerClassLoadingLocalClassPathExclude()); - } - - /** - * @return Whether peer-to-peer class loading is enabled. - */ - public boolean isPeerClassLoadingEnabled() { - return p2pEnabled; - } - - /** - * @return Missed resource cache size. - */ - public int getPeerClassLoadingMissedResourcesCacheSize() { - return p2pMissedResCacheSize; - } - - /** - * @return List of packages from the system classpath that need to be loaded from task originating node. - */ - @Nullable public List getPeerClassLoadingLocalClassPathExclude() { - return p2pLocClsPathExcl; - } - - /** {@inheritDoc} */ - @Override protected void writeExternalData(ObjectOutput out) throws IOException { - out.writeBoolean(p2pEnabled); - out.writeInt(p2pMissedResCacheSize); - U.writeCollection(out, p2pLocClsPathExcl); - } - - /** {@inheritDoc} */ - @Override protected void readExternalData(byte protoVer, ObjectInput in) throws IOException, ClassNotFoundException { - p2pEnabled = in.readBoolean(); - p2pMissedResCacheSize = in.readInt(); - p2pLocClsPathExcl = U.readList(in); - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorPeerToPeerConfiguration.class, this); - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorPersistenceMetrics.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorPersistenceMetrics.java deleted file mode 100644 index 0a363ede5b22c..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorPersistenceMetrics.java +++ /dev/null @@ -1,481 +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.node; - -import java.io.IOException; -import java.io.ObjectInput; -import java.io.ObjectOutput; - -import org.apache.ignite.internal.processors.metric.GridMetricManager; -import org.apache.ignite.internal.processors.metric.impl.HitRateMetric; -import org.apache.ignite.internal.util.typedef.internal.S; -import org.apache.ignite.internal.visor.VisorDataTransferObject; -import org.apache.ignite.spi.metric.DoubleMetric; -import org.apache.ignite.spi.metric.IntMetric; -import org.apache.ignite.spi.metric.LongMetric; -import org.apache.ignite.spi.metric.ReadOnlyMetricRegistry; - -import static org.apache.ignite.internal.processors.cache.persistence.DataStorageMetricsImpl.DATASTORAGE_METRIC_PREFIX; - -/** - */ -public class VisorPersistenceMetrics extends VisorDataTransferObject { - /** */ - private static final long serialVersionUID = 0L; - - /** */ - private float walLoggingRate; - - /** */ - private float walWritingRate; - - /** */ - private int walArchiveSegments; - - /** */ - private float walFsyncTimeAvg; - - /** */ - private long walBufPollSpinRate; - - /** */ - private long walSz; - - /** */ - private long walLastRollOverTm; - - /** */ - private long cpTotalTm; - - /** */ - private long lastCpDuration; - - /** */ - private long lastCpStart; - - /** */ - private long lastCpLockWaitDuration; - - /** */ - private long lastCpMmarkDuration; - - /** */ - private long lastCpPagesWriteDuration; - - /** */ - private long lastCpFsyncDuration; - - /** */ - private long lastCpTotalPages; - - /** */ - private long lastCpDataPages; - - /** */ - private long lastCpCowPages; - - /** */ - private long dirtyPages; - - /** */ - private long pagesRead; - - /** */ - private long pagesWritten; - - /** */ - private long pagesReplaced; - - /** */ - private long offHeapSz; - - /** */ - private long offheapUsedSz; - - /** */ - private long usedCpBufPages; - - /** */ - private long usedCpBufSz; - - /** */ - private long cpBufSz; - - /** */ - private long totalSz; - - /** */ - private long storageSize; - - /** */ - private long sparseStorageSize; - - /** - * Default constructor. - */ - public VisorPersistenceMetrics() { - // No-op. - } - - /** - * @param m Persistence metrics. - */ - public VisorPersistenceMetrics(GridMetricManager gmm) { - - ReadOnlyMetricRegistry mreg = gmm.registry(DATASTORAGE_METRIC_PREFIX); - - walLoggingRate = ((float)mreg.findMetric("WalLoggingRate").value() * 1000 / mreg.findMetric("WalLoggingRate").rateTimeInterval()); - walWritingRate = ((float)mreg.findMetric("WalWritingRate").value() * 1000 / mreg.findMetric("WalWritingRate").rateTimeInterval()); - walArchiveSegments = mreg.findMetric("WalArchiveSegments").value(); - walFsyncTimeAvg = (float)mreg.findMetric("walFsyncTimeAverage").value(); - walBufPollSpinRate = mreg.findMetric("WalBuffPollSpinsRate").value(); - walSz = mreg.findMetric("WalTotalSize").value(); - walLastRollOverTm = mreg.findMetric("WalLastRollOverTime").value(); - - cpTotalTm = mreg.findMetric("CheckpointTotalTime").value(); - - lastCpDuration = mreg.findMetric("LastCheckpointDuration").value(); - lastCpStart = mreg.findMetric("LastCheckpointStart").value(); - lastCpLockWaitDuration = mreg.findMetric("LastCheckpointLockWaitDuration").value(); - lastCpMmarkDuration = mreg.findMetric("LastCheckpointMarkDuration").value(); - lastCpPagesWriteDuration = mreg.findMetric("LastCheckpointPagesWriteDuration").value(); - lastCpFsyncDuration = mreg.findMetric("LastCheckpointFsyncDuration").value(); - lastCpTotalPages = mreg.findMetric("LastCheckpointTotalPagesNumber").value(); - lastCpDataPages = mreg.findMetric("LastCheckpointDataPagesNumber").value(); - lastCpCowPages = mreg.findMetric("LastCheckpointCopiedOnWritePagesNumber").value(); - - dirtyPages = mreg.findMetric("DirtyPages").value(); - pagesRead = mreg.findMetric("PagesRead").value(); - pagesWritten = mreg.findMetric("PagesWritten").value(); - pagesReplaced = mreg.findMetric("PagesReplaced").value(); - - offHeapSz = mreg.findMetric("OffHeapSize").value(); - offheapUsedSz = mreg.findMetric("OffheapUsedSize").value(); - - mreg.findMetric("UsedCheckpointBufferPages"); - mreg.findMetric("UsedCheckpointBufferSize"); - mreg.findMetric("UsedCheckpointBufferSize"); - - usedCpBufPages = mreg.findMetric("UsedCheckpointBufferPages").value(); - usedCpBufSz = mreg.findMetric("UsedCheckpointBufferSize").value(); - cpBufSz = mreg.findMetric("UsedCheckpointBufferSize").value(); - - totalSz = mreg.findMetric("TotalAllocatedSize").value(); - - mreg.findMetric("StorageSize"); - mreg.findMetric("SparseStorageSize"); - - storageSize = mreg.findMetric("StorageSize").value(); - sparseStorageSize = mreg.findMetric("SparseStorageSize").value(); - - } - - /** - * @return Average number of WAL records per second written during the last time interval. - */ - public float getWalLoggingRate() { - return walLoggingRate; - } - - /** - * @return Average number of bytes per second written during the last time interval. - */ - public float getWalWritingRate() { - return walWritingRate; - } - - /** - * @return Current number of WAL segments in the WAL archive. - */ - public int getWalArchiveSegments() { - return walArchiveSegments; - } - - /** - * @return Average WAL fsync duration in microseconds over the last time interval. - */ - public float getWalFsyncTimeAverage() { - return walFsyncTimeAvg; - } - - /** - * @return WAL buffer poll spins number over the last time interval. - */ - public long getWalBuffPollSpinsRate() { - return walBufPollSpinRate; - } - - /** - * @return Total size in bytes for storage WAL files. - */ - public long getWalTotalSize() { - return walSz; - } - - /** - * @return Time of the last WAL segment rollover. - */ - public long getWalLastRollOverTime() { - return walLastRollOverTm; - } - - /** - * @return Total checkpoint time from last restart. - */ - public long getCheckpointTotalTime() { - return cpTotalTm; - } - - /** - * @return Total checkpoint duration in milliseconds. - */ - public long getLastCheckpointingDuration() { - return lastCpDuration; - } - - /** - * Returns time when the last checkpoint was started. - * - * @return Time when the last checkpoint was started. - * */ - public long getLastCheckpointStarted() { - return lastCpStart; - } - - /** - * @return Checkpoint lock wait time in milliseconds. - */ - public long getLastCheckpointLockWaitDuration() { - return lastCpLockWaitDuration; - } - - /** - * @return Checkpoint mark duration in milliseconds. - */ - public long getLastCheckpointMarkDuration() { - return lastCpMmarkDuration; - } - - /** - * @return Checkpoint pages write phase in milliseconds. - */ - public long getLastCheckpointPagesWriteDuration() { - return lastCpPagesWriteDuration; - } - - /** - * @return Checkpoint fsync time in milliseconds. - */ - public long getLastCheckpointFsyncDuration() { - return lastCpFsyncDuration; - } - - /** - * @return Total number of pages written during the last checkpoint. - */ - public long getLastCheckpointTotalPagesNumber() { - return lastCpTotalPages; - } - - /** - * @return Total number of data pages written during the last checkpoint. - */ - public long getLastCheckpointDataPagesNumber() { - return lastCpDataPages; - } - - /** - * @return Total number of pages copied to a temporary checkpoint buffer during the last checkpoint. - */ - public long getLastCheckpointCopiedOnWritePagesNumber() { - return lastCpCowPages; - } - - /** - * @return Total dirty pages for the next checkpoint. - */ - public long getDirtyPages() { - return dirtyPages; - } - - /** - * @return The number of read pages from last restart. - */ - public long getPagesRead() { - return pagesRead; - } - - /** - * @return The number of written pages from last restart. - */ - public long getPagesWritten() { - return pagesWritten; - } - - /** - * @return The number of replaced pages from last restart. - */ - public long getPagesReplaced() { - return pagesReplaced; - } - - /** - * @return Total offheap size in bytes. - */ - public long getOffHeapSize() { - return offHeapSz; - } - - /** - * @return Total used offheap size in bytes. - */ - public long getOffheapUsedSize() { - return offheapUsedSz; - } - - /** - * @return Checkpoint buffer size in pages. - */ - public long getUsedCheckpointBufferPages() { - return usedCpBufPages; - } - - /** - * @return Checkpoint buffer size in bytes. - */ - public long getUsedCheckpointBufferSize() { - return usedCpBufSz; - } - - /** - * @return Checkpoint buffer size in bytes. - */ - public long getCheckpointBufferSize() { - return cpBufSz; - } - - /** - * @return Total size of memory allocated in bytes. - */ - public long getTotalAllocatedSize() { - return totalSz; - } - - /** - * @return Storage space allocated in bytes. - */ - public long getStorageSize() { - return storageSize; - } - - /** - * @return Storage space allocated adjusted for possible sparsity in bytes. - */ - public long getSparseStorageSize() { - return sparseStorageSize; - } - - /** {@inheritDoc} */ - @Override public byte getProtocolVersion() { - return V5; - } - - /** {@inheritDoc} */ - @Override protected void writeExternalData(ObjectOutput out) throws IOException { - out.writeFloat(walLoggingRate); - out.writeFloat(walWritingRate); - out.writeInt(walArchiveSegments); - out.writeFloat(walFsyncTimeAvg); - out.writeLong(lastCpDuration); - out.writeLong(lastCpLockWaitDuration); - out.writeLong(lastCpMmarkDuration); - out.writeLong(lastCpPagesWriteDuration); - out.writeLong(lastCpFsyncDuration); - out.writeLong(lastCpTotalPages); - out.writeLong(lastCpDataPages); - out.writeLong(lastCpCowPages); - - // V2 - out.writeLong(walBufPollSpinRate); - out.writeLong(walSz); - out.writeLong(walLastRollOverTm); - out.writeLong(cpTotalTm); - out.writeLong(dirtyPages); - out.writeLong(pagesRead); - out.writeLong(pagesWritten); - out.writeLong(pagesReplaced); - out.writeLong(offHeapSz); - out.writeLong(offheapUsedSz); - out.writeLong(usedCpBufPages); - out.writeLong(usedCpBufSz); - out.writeLong(cpBufSz); - out.writeLong(totalSz); - - // V3 - out.writeLong(storageSize); - out.writeLong(sparseStorageSize); - - // V4 - out.writeLong(lastCpStart); - } - - /** {@inheritDoc} */ - @Override protected void readExternalData(byte protoVer, ObjectInput in) throws IOException, ClassNotFoundException { - walLoggingRate = in.readFloat(); - walWritingRate = in.readFloat(); - walArchiveSegments = in.readInt(); - walFsyncTimeAvg = in.readFloat(); - lastCpDuration = in.readLong(); - lastCpLockWaitDuration = in.readLong(); - lastCpMmarkDuration = in.readLong(); - lastCpPagesWriteDuration = in.readLong(); - lastCpFsyncDuration = in.readLong(); - lastCpTotalPages = in.readLong(); - lastCpDataPages = in.readLong(); - lastCpCowPages = in.readLong(); - - if (protoVer > V1) { - walBufPollSpinRate = in.readLong(); - walSz = in.readLong(); - walLastRollOverTm = in.readLong(); - cpTotalTm = in.readLong(); - dirtyPages = in.readLong(); - pagesRead = in.readLong(); - pagesWritten = in.readLong(); - pagesReplaced = in.readLong(); - offHeapSz = in.readLong(); - offheapUsedSz = in.readLong(); - usedCpBufPages = in.readLong(); - usedCpBufSz = in.readLong(); - cpBufSz = in.readLong(); - totalSz = in.readLong(); - } - - if (protoVer > V2) { - storageSize = in.readLong(); - sparseStorageSize = in.readLong(); - } - - if (protoVer > V3) - lastCpStart = in.readLong(); - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorPersistenceMetrics.class, this); - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorPersistentStoreConfiguration.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorPersistentStoreConfiguration.java deleted file mode 100644 index 986f0ee0c54c8..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorPersistentStoreConfiguration.java +++ /dev/null @@ -1,306 +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.node; - -import java.io.IOException; -import java.io.ObjectInput; -import java.io.ObjectOutput; -import org.apache.ignite.configuration.DataStorageConfiguration; -import org.apache.ignite.configuration.WALMode; -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; - -/** - * DTO object for {@link DataStorageConfiguration}. - */ -public class VisorPersistentStoreConfiguration extends VisorDataTransferObject { - /** */ - private static final long serialVersionUID = 0L; - - /** */ - private String persistenceStorePath; - - /** Checkpointing frequency. */ - private long checkpointingFreq; - - /** Lock wait time. */ - private long lockWaitTime; - - /** */ - private long checkpointingPageBufSize; - - /** */ - private int checkpointingThreads; - - /** */ - private int walHistSize; - - /** Number of work WAL segments. */ - private int walSegments; - - /** Number of WAL segments to keep. */ - private int walSegmentSize; - - /** WAL persistence path. */ - private String walStorePath; - - /** WAL archive path. */ - private String walArchivePath; - - /** Metrics enabled flag. */ - private boolean metricsEnabled; - - /** Wal mode. */ - private WALMode walMode; - - /** WAl thread local buffer size. */ - private int tlbSize; - - /** Wal flush frequency. */ - private long walFlushFreq; - - /** Wal fsync delay in nanoseconds. */ - private long walFsyncDelay; - - /** Wal record iterator buffer size. */ - private int walRecordIterBuffSize; - - /** Always write full pages. */ - private boolean alwaysWriteFullPages; - - /** Number of sub-intervals. */ - private int subIntervals; - - /** Time interval (in milliseconds) for rate-based metrics. */ - private long rateTimeInterval; - - /** - * Default constructor. - */ - public VisorPersistentStoreConfiguration() { - // No-op. - } - - /** - * @param cfg Persistent store configuration. - */ - public VisorPersistentStoreConfiguration(DataStorageConfiguration cfg) { - persistenceStorePath = cfg.getStoragePath(); - checkpointingFreq = cfg.getCheckpointFrequency(); - lockWaitTime = cfg.getLockWaitTime(); - checkpointingThreads = cfg.getCheckpointThreads(); - walHistSize = cfg.getWalHistorySize(); - walSegments = cfg.getWalSegments(); - walSegmentSize = cfg.getWalSegmentSize(); - walStorePath = cfg.getWalPath(); - walArchivePath = cfg.getWalArchivePath(); - metricsEnabled = cfg.isMetricsEnabled(); - walMode = cfg.getWalMode(); - tlbSize = cfg.getWalBufferSize(); - walFlushFreq = cfg.getWalFlushFrequency(); - walFsyncDelay = cfg.getWalFsyncDelayNanos(); - walRecordIterBuffSize = cfg.getWalRecordIteratorBufferSize(); - alwaysWriteFullPages = cfg.isAlwaysWriteFullPages(); - subIntervals = cfg.getMetricsSubIntervalCount(); - rateTimeInterval = cfg.getMetricsRateTimeInterval(); - } - - /** - * @return Path the root directory where the Persistent Store will persist data and indexes. - */ - public String getPersistentStorePath() { - return persistenceStorePath; - } - - /** - * @return Checkpointing frequency in milliseconds. - */ - public long getCheckpointingFrequency() { - return checkpointingFreq; - } - - /** - * @return Checkpointing page buffer size in bytes. - */ - public long getCheckpointingPageBufferSize() { - return checkpointingPageBufSize; - } - - /** - * @return Number of checkpointing threads. - */ - public int getCheckpointingThreads() { - return checkpointingThreads; - } - - /** - * @return Time for wait. - */ - public long getLockWaitTime() { - return lockWaitTime; - } - - /** - * @return Number of WAL segments to keep after a checkpoint is finished. - */ - public int getWalHistorySize() { - return walHistSize; - } - - /** - * @return Number of work WAL segments. - */ - public int getWalSegments() { - return walSegments; - } - - /** - * @return WAL segment size. - */ - public int getWalSegmentSize() { - return walSegmentSize; - } - - /** - * @return WAL persistence path, absolute or relative to Ignite work directory. - */ - public String getWalStorePath() { - return walStorePath; - } - - /** - * @return WAL archive directory. - */ - public String getWalArchivePath() { - return walArchivePath; - } - - /** - * @return Metrics enabled flag. - */ - public boolean isMetricsEnabled() { - return metricsEnabled; - } - - /** - * @return Time interval in milliseconds. - */ - public long getRateTimeInterval() { - return rateTimeInterval; - } - - /** - * @return The number of sub-intervals for history tracking. - */ - public int getSubIntervals() { - return subIntervals; - } - - /** - * @return WAL mode. - */ - public WALMode getWalMode() { - return walMode; - } - - /** - * @return Thread local buffer size. - */ - public int getTlbSize() { - return tlbSize; - } - - /** - * @return Flush frequency. - */ - public long getWalFlushFrequency() { - return walFlushFreq; - } - - /** - * Gets the fsync delay, in nanoseconds. - */ - public long getWalFsyncDelayNanos() { - return walFsyncDelay; - } - - /** - * @return Record iterator buffer size. - */ - public int getWalRecordIteratorBufferSize() { - return walRecordIterBuffSize; - } - - /** - * - */ - public boolean isAlwaysWriteFullPages() { - return alwaysWriteFullPages; - } - - /** {@inheritDoc} */ - @Override protected void writeExternalData(ObjectOutput out) throws IOException { - U.writeString(out, persistenceStorePath); - out.writeLong(checkpointingFreq); - out.writeLong(lockWaitTime); - out.writeLong(checkpointingPageBufSize); - out.writeInt(checkpointingThreads); - out.writeInt(walHistSize); - out.writeInt(walSegments); - out.writeInt(walSegmentSize); - U.writeString(out, walStorePath); - U.writeString(out, walArchivePath); - out.writeBoolean(metricsEnabled); - U.writeEnum(out, walMode); - out.writeInt(tlbSize); - out.writeLong(walFlushFreq); - out.writeLong(walFsyncDelay); - out.writeInt(walRecordIterBuffSize); - out.writeBoolean(alwaysWriteFullPages); - out.writeInt(subIntervals); - out.writeLong(rateTimeInterval); - } - - /** {@inheritDoc} */ - @Override protected void readExternalData(byte protoVer, ObjectInput in) throws IOException, ClassNotFoundException { - persistenceStorePath = U.readString(in); - checkpointingFreq = in.readLong(); - lockWaitTime = in.readLong(); - checkpointingPageBufSize = in.readLong(); - checkpointingThreads = in.readInt(); - walHistSize = in.readInt(); - walSegments = in.readInt(); - walSegmentSize = in.readInt(); - walStorePath = U.readString(in); - walArchivePath = U.readString(in); - metricsEnabled = in.readBoolean(); - walMode = WALMode.fromOrdinal(in.readByte()); - tlbSize = in.readInt(); - walFlushFreq = in.readLong(); - walFsyncDelay = in.readLong(); - walRecordIterBuffSize = in.readInt(); - alwaysWriteFullPages = in.readBoolean(); - subIntervals = in.readInt(); - rateTimeInterval = in.readLong(); - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorPersistentStoreConfiguration.class, this); - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorRestConfiguration.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorRestConfiguration.java deleted file mode 100644 index baf0ea6a3eb32..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorRestConfiguration.java +++ /dev/null @@ -1,366 +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.node; - -import java.io.IOException; -import java.io.ObjectInput; -import java.io.ObjectOutput; -import org.apache.ignite.configuration.ConnectorConfiguration; -import org.apache.ignite.configuration.IgniteConfiguration; -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 java.lang.System.getProperty; -import static org.apache.ignite.IgniteSystemProperties.IGNITE_JETTY_HOST; -import static org.apache.ignite.IgniteSystemProperties.IGNITE_JETTY_PORT; -import static org.apache.ignite.internal.visor.util.VisorTaskUtils.compactClass; -import static org.apache.ignite.internal.visor.util.VisorTaskUtils.intValue; - -/** - * Create data transfer object for node REST configuration properties. - */ -public class VisorRestConfiguration extends VisorDataTransferObject { - /** */ - private static final long serialVersionUID = 0L; - - /** Whether REST enabled or not. */ - private boolean restEnabled; - - /** Whether or not SSL is enabled for TCP binary protocol. */ - private boolean tcpSslEnabled; - - /** Jetty config path. */ - private String jettyPath; - - /** Jetty host. */ - private String jettyHost; - - /** Jetty port. */ - private Integer jettyPort; - - /** REST TCP binary host. */ - private String tcpHost; - - /** REST TCP binary port. */ - private int tcpPort; - - /** Context factory for SSL. */ - private String tcpSslCtxFactory; - - /** REST secret key. */ - private String secretKey; - - /** TCP no delay flag. */ - private boolean noDelay; - - /** REST TCP direct buffer flag. */ - private boolean directBuf; - - /** REST TCP send buffer size. */ - private int sndBufSize; - - /** REST TCP receive buffer size. */ - private int rcvBufSize; - - /** REST idle timeout for query cursor. */ - private long idleQryCurTimeout; - - /** REST idle check frequency for query cursor. */ - private long idleQryCurCheckFreq; - - /** REST TCP send queue limit. */ - private int sndQueueLimit; - - /** REST TCP selector count. */ - private int selectorCnt; - - /** Idle timeout. */ - private long idleTimeout; - - /** SSL need client auth flag. */ - private boolean sslClientAuth; - - /** SSL context factory for rest binary server. */ - private String sslFactory; - - /** Port range */ - private int portRange; - - /** Client message interceptor. */ - private String msgInterceptor; - - /** - * Default constructor. - */ - public VisorRestConfiguration() { - // No-op. - } - - /** - * Create data transfer object for node REST configuration properties. - * - * @param c Grid configuration. - */ - public VisorRestConfiguration(IgniteConfiguration c) { - assert c != null; - - ConnectorConfiguration conCfg = c.getConnectorConfiguration(); - - restEnabled = conCfg != null; - - if (restEnabled) { - tcpSslEnabled = conCfg.isSslEnabled(); - jettyPath = conCfg.getJettyPath(); - jettyHost = getProperty(IGNITE_JETTY_HOST); - jettyPort = intValue(IGNITE_JETTY_PORT, null); - tcpHost = conCfg.getHost(); - tcpPort = conCfg.getPort(); - tcpSslCtxFactory = compactClass(conCfg.getSslContextFactory()); - secretKey = conCfg.getSecretKey(); - noDelay = conCfg.isNoDelay(); - directBuf = conCfg.isDirectBuffer(); - sndBufSize = conCfg.getSendBufferSize(); - rcvBufSize = conCfg.getReceiveBufferSize(); - idleQryCurTimeout = conCfg.getIdleQueryCursorTimeout(); - idleQryCurCheckFreq = conCfg.getIdleQueryCursorCheckFrequency(); - sndQueueLimit = conCfg.getSendQueueLimit(); - selectorCnt = conCfg.getSelectorCount(); - idleTimeout = conCfg.getIdleTimeout(); - sslClientAuth = conCfg.isSslClientAuth(); - sslFactory = compactClass(conCfg.getSslFactory()); - portRange = conCfg.getPortRange(); - msgInterceptor = compactClass(conCfg.getMessageInterceptor()); - } - } - - /** - * @return Whether REST enabled or not. - */ - public boolean isRestEnabled() { - return restEnabled; - } - - /** - * @return Whether or not SSL is enabled for TCP binary protocol. - */ - public boolean isTcpSslEnabled() { - return tcpSslEnabled; - } - - /** - * @return Jetty config path. - */ - @Nullable public String getJettyPath() { - return jettyPath; - } - - /** - * @return Jetty host. - */ - @Nullable public String getJettyHost() { - return jettyHost; - } - - /** - * @return Jetty port. - */ - @Nullable public Integer getJettyPort() { - return jettyPort; - } - - /** - * @return REST TCP binary host. - */ - @Nullable public String getTcpHost() { - return tcpHost; - } - - /** - * @return REST TCP binary port. - */ - public int getTcpPort() { - return tcpPort; - } - - /** - * @return Context factory for SSL. - */ - @Nullable public String getTcpSslContextFactory() { - return tcpSslCtxFactory; - } - - /** - * @return Secret key. - */ - @Nullable public String getSecretKey() { - return secretKey; - } - - /** - * @return Whether {@code TCP_NODELAY} option should be enabled. - */ - public boolean isNoDelay() { - return noDelay; - } - - /** - * @return Whether direct buffer should be used. - */ - public boolean isDirectBuffer() { - return directBuf; - } - - /** - * @return REST TCP server send buffer size (0 for default). - */ - public int getSendBufferSize() { - return sndBufSize; - } - - /** - * @return REST TCP server receive buffer size (0 for default). - */ - public int getReceiveBufferSize() { - return rcvBufSize; - } - - /** - * @return Idle query cursors timeout in milliseconds - */ - public long getIdleQueryCursorTimeout() { - return idleQryCurTimeout; - } - - /** - * @return Idle query cursor check frequency in milliseconds. - */ - public long getIdleQueryCursorCheckFrequency() { - return idleQryCurCheckFreq; - } - - /** - * @return REST TCP server send queue limit (0 for unlimited). - */ - public int getSendQueueLimit() { - return sndQueueLimit; - } - - /** - * @return Number of selector threads for REST TCP server. - */ - public int getSelectorCount() { - return selectorCnt; - } - - /** - * @return Idle timeout in milliseconds. - */ - public long getIdleTimeout() { - return idleTimeout; - } - - /** - * Gets a flag indicating whether or not remote clients will be required to have a valid SSL certificate which - * validity will be verified with trust manager. - * - * @return Whether or not client authentication is required. - */ - public boolean isSslClientAuth() { - return sslClientAuth; - } - - /** - * @return SslContextFactory instance. - */ - public String getSslFactory() { - return sslFactory; - } - - /** - * @return Number of ports to try. - */ - public int getPortRange() { - return portRange; - } - - /** - * @return Interceptor. - */ - @Nullable public String getMessageInterceptor() { - return msgInterceptor; - } - - /** {@inheritDoc} */ - @Override protected void writeExternalData(ObjectOutput out) throws IOException { - out.writeBoolean(restEnabled); - out.writeBoolean(tcpSslEnabled); - U.writeString(out, jettyPath); - U.writeString(out, jettyHost); - out.writeObject(jettyPort); - U.writeString(out, tcpHost); - out.writeInt(tcpPort); - U.writeString(out, tcpSslCtxFactory); - U.writeString(out, secretKey); - out.writeBoolean(noDelay); - out.writeBoolean(directBuf); - out.writeInt(sndBufSize); - out.writeInt(rcvBufSize); - out.writeLong(idleQryCurTimeout); - out.writeLong(idleQryCurCheckFreq); - out.writeInt(sndQueueLimit); - out.writeInt(selectorCnt); - out.writeLong(idleTimeout); - out.writeBoolean(sslClientAuth); - U.writeString(out, sslFactory); - out.writeInt(portRange); - U.writeString(out, msgInterceptor); - } - - /** {@inheritDoc} */ - @Override protected void readExternalData(byte protoVer, ObjectInput in) throws IOException, ClassNotFoundException { - restEnabled = in.readBoolean(); - tcpSslEnabled = in.readBoolean(); - jettyPath = U.readString(in); - jettyHost = U.readString(in); - jettyPort = (Integer)in.readObject(); - tcpHost = U.readString(in); - tcpPort = in.readInt(); - tcpSslCtxFactory = U.readString(in); - secretKey = U.readString(in); - noDelay = in.readBoolean(); - directBuf = in.readBoolean(); - sndBufSize = in.readInt(); - rcvBufSize = in.readInt(); - idleQryCurTimeout = in.readLong(); - idleQryCurCheckFreq = in.readLong(); - sndQueueLimit = in.readInt(); - selectorCnt = in.readInt(); - idleTimeout = in.readLong(); - sslClientAuth = in.readBoolean(); - sslFactory = U.readString(in); - portRange = in.readInt(); - msgInterceptor = U.readString(in); - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorRestConfiguration.class, this); - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorSegmentationConfiguration.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorSegmentationConfiguration.java deleted file mode 100644 index 5e4dd4089f6f7..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorSegmentationConfiguration.java +++ /dev/null @@ -1,144 +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.node; - -import java.io.IOException; -import java.io.ObjectInput; -import java.io.ObjectOutput; -import org.apache.ignite.configuration.IgniteConfiguration; -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.plugin.segmentation.SegmentationPolicy; -import org.jetbrains.annotations.Nullable; - -import static org.apache.ignite.internal.visor.util.VisorTaskUtils.compactArray; - -/** - * Data transfer object for node segmentation configuration properties. - */ -public class VisorSegmentationConfiguration extends VisorDataTransferObject { - /** */ - private static final long serialVersionUID = 0L; - - /** Segmentation policy. */ - private SegmentationPolicy plc; - - /** Segmentation resolvers. */ - private String resolvers; - - /** Frequency of network segment check by discovery manager. */ - private long checkFreq; - - /** Whether or not node should wait for correct segment on start. */ - private boolean waitOnStart; - - /** Whether or not all resolvers should succeed for node to be in correct segment. */ - private boolean allResolversPassReq; - - /** Segmentation resolve attempts count. */ - private int segResolveAttempts; - - /** - * Default constructor. - */ - public VisorSegmentationConfiguration() { - // No-op. - } - - /** - * Create data transfer object for node segmentation configuration properties. - * - * @param c Grid configuration. - */ - public VisorSegmentationConfiguration(IgniteConfiguration c) { - plc = c.getSegmentationPolicy(); - resolvers = compactArray(c.getSegmentationResolvers()); - checkFreq = c.getSegmentCheckFrequency(); - waitOnStart = c.isWaitForSegmentOnStart(); - allResolversPassReq = c.isAllSegmentationResolversPassRequired(); - segResolveAttempts = c.getSegmentationResolveAttempts(); - } - - /** - * @return Segmentation policy. - */ - public SegmentationPolicy getPolicy() { - return plc; - } - - /** - * @return Segmentation resolvers. - */ - @Nullable public String getResolvers() { - return resolvers; - } - - /** - * @return Frequency of network segment check by discovery manager. - */ - public long getCheckFrequency() { - return checkFreq; - } - - /** - * @return Whether or not node should wait for correct segment on start. - */ - public boolean isWaitOnStart() { - return waitOnStart; - } - - /** - * @return Whether or not all resolvers should succeed for node to be in correct segment. - */ - public boolean isAllSegmentationResolversPassRequired() { - return allResolversPassReq; - } - - /** - * @return Segmentation resolve attempts. - */ - public int getSegmentationResolveAttempts() { - return segResolveAttempts; - } - - /** {@inheritDoc} */ - @Override protected void writeExternalData(ObjectOutput out) throws IOException { - U.writeEnum(out, plc); - U.writeString(out, resolvers); - out.writeLong(checkFreq); - out.writeBoolean(waitOnStart); - out.writeBoolean(allResolversPassReq); - out.writeInt(segResolveAttempts); - } - - /** {@inheritDoc} */ - @Override protected void readExternalData(byte protoVer, ObjectInput in) throws IOException, ClassNotFoundException { - plc = SegmentationPolicy.fromOrdinal(in.readByte()); - resolvers = U.readString(in); - checkFreq = in.readLong(); - waitOnStart = in.readBoolean(); - allResolversPassReq = in.readBoolean(); - segResolveAttempts = in.readInt(); - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorSegmentationConfiguration.class, this); - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorServiceConfiguration.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorServiceConfiguration.java deleted file mode 100644 index 9092cc2dce0fd..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorServiceConfiguration.java +++ /dev/null @@ -1,175 +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.node; - -import java.io.IOException; -import java.io.ObjectInput; -import java.io.ObjectOutput; -import java.util.ArrayList; -import java.util.List; -import org.apache.ignite.internal.util.typedef.F; -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.services.ServiceConfiguration; - -import static org.apache.ignite.internal.visor.util.VisorTaskUtils.compactClass; - -/** - * Data transfer object for configuration of service data structures. - */ -public class VisorServiceConfiguration extends VisorDataTransferObject { - /** */ - private static final long serialVersionUID = 0L; - - /** Service name. */ - private String name; - - /** Service instance. */ - private String svc; - - /** Total count. */ - private int totalCnt; - - /** Max per-node count. */ - private int maxPerNodeCnt; - - /** Cache name. */ - private String cacheName; - - /** Affinity key. */ - private String affKey; - - /** Node filter. */ - private String nodeFilter; - - /** - * Construct data transfer object for service configurations properties. - * - * @param cfgs Service configurations. - * @return Service configurations properties. - */ - public static List list(ServiceConfiguration[] cfgs) { - List res = new ArrayList<>(); - - if (!F.isEmpty(cfgs)) { - for (ServiceConfiguration cfg : cfgs) - res.add(new VisorServiceConfiguration(cfg)); - } - - return res; - } - - /** - * Default constructor. - */ - public VisorServiceConfiguration() { - // No-op. - } - - /** - * Create data transfer object for service configuration. - * - * @param src Service configuration. - */ - public VisorServiceConfiguration(ServiceConfiguration src) { - name = src.getName(); - svc = compactClass(src.getService()); - totalCnt = src.getTotalCount(); - maxPerNodeCnt = src.getMaxPerNodeCount(); - cacheName = src.getCacheName(); - affKey = compactClass(src.getAffinityKey()); - nodeFilter = compactClass(src.getNodeFilter()); - } - - /** - * @return Service name. - */ - public String getName() { - return name; - } - - /** - * @return Service instance. - */ - public String getService() { - return svc; - } - - /** - * @return Total number of deployed service instances in the cluster, {@code 0} for unlimited. - */ - public int getTotalCount() { - return totalCnt; - } - - /** - * @return Maximum number of deployed service instances on each node, {@code 0} for unlimited. - */ - public int getMaxPerNodeCount() { - return maxPerNodeCnt; - } - - /** - * @return Cache name, possibly {@code null}. - */ - public String getCacheName() { - return cacheName; - } - - /** - * @return Affinity key, possibly {@code null}. - */ - public String getAffinityKey() { - return affKey; - } - - /** - * @return Node filter used to filter nodes on which the service will be deployed, possibly {@code null}. - */ - public String getNodeFilter() { - return nodeFilter; - } - - /** {@inheritDoc} */ - @Override protected void writeExternalData(ObjectOutput out) throws IOException { - U.writeString(out, name); - U.writeString(out, svc); - out.writeInt(totalCnt); - out.writeInt(maxPerNodeCnt); - U.writeString(out, cacheName); - U.writeString(out, affKey); - U.writeString(out, nodeFilter); - } - - /** {@inheritDoc} */ - @Override protected void readExternalData(byte protoVer, ObjectInput in) throws IOException, ClassNotFoundException { - name = U.readString(in); - svc = U.readString(in); - totalCnt = in.readInt(); - maxPerNodeCnt = in.readInt(); - cacheName = U.readString(in); - affKey = U.readString(in); - nodeFilter = U.readString(in); - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorServiceConfiguration.class, this); - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorSpiDescription.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorSpiDescription.java deleted file mode 100644 index 2d1eb48f591aa..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorSpiDescription.java +++ /dev/null @@ -1,89 +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.node; - -import java.io.IOException; -import java.io.ObjectInput; -import java.io.ObjectOutput; -import java.util.Map; -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; - -/** - * Transfer object for single spi description. - */ -public class VisorSpiDescription extends VisorDataTransferObject { - /** */ - private static final long serialVersionUID = 0L; - - /** SPI class name. */ - private String clsName; - - /** SPI fields description. */ - private Map fldDesc; - - /** - * Default constructor. - */ - public VisorSpiDescription() { - // No-op. - } - - /** - * Construct Visor spi description object. - * - * @param clsName SPI class name. - * @param fldDesc SPI fields description. - */ - public VisorSpiDescription(String clsName, Map fldDesc) { - this.clsName = clsName; - this.fldDesc = fldDesc; - } - - /** - * @return SPI class name. - */ - public String getClassName() { - return clsName; - } - - /** - * @return SPI fields description. - */ - public Map getFieldDescriptions() { - return fldDesc; - } - - /** {@inheritDoc} */ - @Override protected void writeExternalData(ObjectOutput out) throws IOException { - U.writeString(out, clsName); - U.writeMap(out, fldDesc); - } - - /** {@inheritDoc} */ - @Override protected void readExternalData(byte protoVer, ObjectInput in) throws IOException, ClassNotFoundException { - clsName = U.readString(in); - fldDesc = U.readMap(in); - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorSpiDescription.class, this); - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorSpisConfiguration.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorSpisConfiguration.java deleted file mode 100644 index 83cc7c1eaf0d0..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorSpisConfiguration.java +++ /dev/null @@ -1,256 +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.node; - -import java.io.IOException; -import java.io.ObjectInput; -import java.io.ObjectOutput; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.util.HashMap; -import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.internal.util.typedef.F; -import org.apache.ignite.internal.util.typedef.internal.S; -import org.apache.ignite.internal.visor.VisorDataTransferObject; -import org.apache.ignite.spi.IgniteSpi; -import org.apache.ignite.spi.IgniteSpiConfiguration; - -import static org.apache.ignite.internal.visor.util.VisorTaskUtils.compactClass; -import static org.apache.ignite.internal.visor.util.VisorTaskUtils.compactObject; - -/** - * Data transfer object for node SPIs configuration properties. - */ -public class VisorSpisConfiguration extends VisorDataTransferObject { - /** */ - private static final long serialVersionUID = 0L; - - /** Discovery SPI. */ - private VisorSpiDescription discoSpi; - - /** Communication SPI. */ - private VisorSpiDescription commSpi; - - /** Event storage SPI. */ - private VisorSpiDescription evtSpi; - - /** Collision SPI. */ - private VisorSpiDescription colSpi; - - /** Deployment SPI. */ - private VisorSpiDescription deploySpi; - - /** Checkpoint SPIs. */ - private VisorSpiDescription[] cpSpis; - - /** Failover SPIs. */ - private VisorSpiDescription[] failSpis; - - /** Load balancing SPIs. */ - private VisorSpiDescription[] loadBalancingSpis; - - /** Indexing SPIs. */ - private VisorSpiDescription[] indexingSpis; - - /** - * Default constructor. - */ - public VisorSpisConfiguration() { - // No-op. - } - - /** - * Collects SPI information based on GridSpiConfiguration-annotated methods. - * Methods with {@code Deprecated} annotation are skipped. - * - * @param spi SPI to collect information on. - * @return Tuple where first component is SPI name and map with properties as second. - */ - private static VisorSpiDescription collectSpiInfo(IgniteSpi spi) { - Class spiCls = spi.getClass(); - - HashMap res = new HashMap<>(); - - res.put("Class Name", compactClass(spi)); - - for (Method mtd : spiCls.getDeclaredMethods()) { - if (mtd.isAnnotationPresent(IgniteSpiConfiguration.class) && !mtd.isAnnotationPresent(Deprecated.class)) { - String mtdName = mtd.getName(); - - if (mtdName.startsWith("set")) { - String propName = Character.toLowerCase(mtdName.charAt(3)) + mtdName.substring(4); - - try { - String[] getterNames = new String[] { - "get" + mtdName.substring(3), - "is" + mtdName.substring(3), - "get" + mtdName.substring(3) + "Formatted" - }; - - for (String getterName : getterNames) { - try { - Method getter = spiCls.getDeclaredMethod(getterName); - - Object getRes = getter.invoke(spi); - - res.put(propName, compactObject(getRes)); - - break; - } - catch (NoSuchMethodException ignored) { - // No-op. - } - } - } - catch (IllegalAccessException ignored) { - res.put(propName, "Error: Method Cannot Be Accessed"); - } - catch (InvocationTargetException ite) { - res.put(propName, ("Error: Method Threw An Exception: " + ite)); - } - } - } - } - - return new VisorSpiDescription(spi.getName(), res); - } - - /** - * @param spis Array of spi to process. - * @return Tuple where first component is SPI name and map with properties as second. - */ - private static VisorSpiDescription[] collectSpiInfo(IgniteSpi[] spis) { - VisorSpiDescription[] res = new VisorSpiDescription[spis.length]; - - for (int i = 0; i < spis.length; i++) - res[i] = collectSpiInfo(spis[i]); - - return res; - } - - /** - * Create data transfer object for node SPIs configuration properties. - * - * @param c Grid configuration. - */ - public VisorSpisConfiguration(IgniteConfiguration c) { - discoSpi = collectSpiInfo(c.getDiscoverySpi()); - commSpi = collectSpiInfo(c.getCommunicationSpi()); - evtSpi = collectSpiInfo(c.getEventStorageSpi()); - colSpi = collectSpiInfo(c.getCollisionSpi()); - deploySpi = collectSpiInfo(c.getDeploymentSpi()); - cpSpis = collectSpiInfo(c.getCheckpointSpi()); - failSpis = collectSpiInfo(c.getFailoverSpi()); - loadBalancingSpis = collectSpiInfo(c.getLoadBalancingSpi()); - indexingSpis = F.asArray(collectSpiInfo(c.getIndexingSpi())); - } - - /** - * @return Discovery SPI. - */ - public VisorSpiDescription getDiscoverySpi() { - return discoSpi; - } - - /** - * @return Communication SPI. - */ - public VisorSpiDescription getCommunicationSpi() { - return commSpi; - } - - /** - * @return Event storage SPI. - */ - public VisorSpiDescription getEventStorageSpi() { - return evtSpi; - } - - /** - * @return Collision SPI. - */ - public VisorSpiDescription getCollisionSpi() { - return colSpi; - } - - /** - * @return Deployment SPI. - */ - public VisorSpiDescription getDeploymentSpi() { - return deploySpi; - } - - /** - * @return Checkpoint SPIs. - */ - public VisorSpiDescription[] getCheckpointSpis() { - return cpSpis; - } - - /** - * @return Failover SPIs. - */ - public VisorSpiDescription[] getFailoverSpis() { - return failSpis; - } - - /** - * @return Load balancing SPIs. - */ - public VisorSpiDescription[] getLoadBalancingSpis() { - return loadBalancingSpis; - } - - /** - * @return Indexing SPIs. - */ - public VisorSpiDescription[] getIndexingSpis() { - return indexingSpis; - } - - /** {@inheritDoc} */ - @Override protected void writeExternalData(ObjectOutput out) throws IOException { - out.writeObject(discoSpi); - out.writeObject(commSpi); - out.writeObject(evtSpi); - out.writeObject(colSpi); - out.writeObject(deploySpi); - out.writeObject(cpSpis); - out.writeObject(failSpis); - out.writeObject(loadBalancingSpis); - out.writeObject(indexingSpis); - } - - /** {@inheritDoc} */ - @Override protected void readExternalData(byte protoVer, ObjectInput in) throws IOException, ClassNotFoundException { - discoSpi = (VisorSpiDescription)in.readObject(); - commSpi = (VisorSpiDescription)in.readObject(); - evtSpi = (VisorSpiDescription)in.readObject(); - colSpi = (VisorSpiDescription)in.readObject(); - deploySpi = (VisorSpiDescription)in.readObject(); - cpSpis = (VisorSpiDescription[])in.readObject(); - failSpis = (VisorSpiDescription[])in.readObject(); - loadBalancingSpis = (VisorSpiDescription[])in.readObject(); - indexingSpis = (VisorSpiDescription[])in.readObject(); - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorSpisConfiguration.class, this); - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorSqlConnectorConfiguration.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorSqlConnectorConfiguration.java deleted file mode 100644 index 2e5466360b95c..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorSqlConnectorConfiguration.java +++ /dev/null @@ -1,170 +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.node; - -import java.io.IOException; -import java.io.ObjectInput; -import java.io.ObjectOutput; -import org.apache.ignite.configuration.SqlConnectorConfiguration; -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; - -/** - * Data transfer object for SQL connector configuration. - * - * Deprecated as of Apache Ignite 2.3 - */ -@Deprecated -public class VisorSqlConnectorConfiguration extends VisorDataTransferObject { - /** */ - private static final long serialVersionUID = 0L; - - /** Host. */ - private String host; - - /** Port. */ - private int port; - - /** Port range. */ - private int portRange; - - /** Max number of opened cursors per connection. */ - private int maxOpenCursorsPerConn; - - /** Socket send buffer size. */ - private int sockSndBufSize; - - /** Socket receive buffer size. */ - private int sockRcvBufSize; - - /** TCP no delay. */ - private boolean tcpNoDelay; - - /** Thread pool size. */ - private int threadPoolSize; - - /** - * Default constructor. - */ - public VisorSqlConnectorConfiguration() { - // No-op. - } - - /** - * Create data transfer object for Sql connector configuration. - * - * @param cfg Sql connector configuration. - */ - public VisorSqlConnectorConfiguration(SqlConnectorConfiguration cfg) { - host = cfg.getHost(); - port = cfg.getPort(); - portRange = cfg.getPortRange(); - maxOpenCursorsPerConn = cfg.getMaxOpenCursorsPerConnection(); - sockSndBufSize = cfg.getSocketSendBufferSize(); - sockRcvBufSize = cfg.getSocketReceiveBufferSize(); - tcpNoDelay = cfg.isTcpNoDelay(); - threadPoolSize = cfg.getThreadPoolSize(); - } - - /** - * @return Host. - */ - @Nullable public String getHost() { - return host; - } - - /** - * @return Port. - */ - public int getPort() { - return port; - } - - /** - * @return Port range. - */ - public int getPortRange() { - return portRange; - } - - /** - * @return Maximum number of opened cursors. - */ - public int getMaxOpenCursorsPerConnection() { - return maxOpenCursorsPerConn; - } - - /** - * @return Socket send buffer size in bytes. - */ - public int getSocketSendBufferSize() { - return sockSndBufSize; - } - - /** - * @return Socket receive buffer size in bytes. - */ - public int getSocketReceiveBufferSize() { - return sockRcvBufSize; - } - - /** - * @return TCP NO_DELAY flag. - */ - public boolean isTcpNoDelay() { - return tcpNoDelay; - } - - /** - * @return Thread pool that is in charge of processing SQL requests. - */ - public int getThreadPoolSize() { - return threadPoolSize; - } - - /** {@inheritDoc} */ - @Override protected void writeExternalData(ObjectOutput out) throws IOException { - U.writeString(out, host); - out.writeInt(port); - out.writeInt(portRange); - out.writeInt(maxOpenCursorsPerConn); - out.writeInt(sockSndBufSize); - out.writeInt(sockRcvBufSize ); - out.writeBoolean(tcpNoDelay); - out.writeInt(threadPoolSize); - } - - /** {@inheritDoc} */ - @Override protected void readExternalData(byte protoVer, ObjectInput in) throws IOException, ClassNotFoundException { - host = U.readString(in); - port = in.readInt(); - portRange = in.readInt(); - maxOpenCursorsPerConn = in.readInt(); - sockSndBufSize = in.readInt(); - sockRcvBufSize = in.readInt(); - tcpNoDelay = in.readBoolean(); - threadPoolSize = in.readInt(); - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorSqlConnectorConfiguration.class, this); - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorSuppressedError.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorSuppressedError.java deleted file mode 100644 index 7c65f98e3e63e..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorSuppressedError.java +++ /dev/null @@ -1,147 +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.node; - -import java.io.IOException; -import java.io.ObjectInput; -import java.io.ObjectOutput; -import org.apache.ignite.internal.util.tostring.GridToStringExclude; -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.internal.visor.util.VisorExceptionWrapper; - -/** - * Data transfer object for suppressed errors. - */ -public class VisorSuppressedError extends VisorDataTransferObject { - /** */ - private static final long serialVersionUID = 0L; - - /** */ - private long order; - - /** */ - @GridToStringExclude - private VisorExceptionWrapper error; - - /** */ - private long threadId; - - /** */ - private String threadName; - - /** */ - private long time; - - /** */ - private String msg; - - /** - * Default constructor. - */ - public VisorSuppressedError() { - // No-op. - } - - /** - * Constructor. - * - * @param order Locally unique ID that is atomically incremented for each new error. - * @param error Suppressed error. - * @param msg Message that describe reason why error was suppressed. - * @param threadId Thread ID. - * @param threadName Thread name. - * @param time Occurrence time. - */ - public VisorSuppressedError(long order, VisorExceptionWrapper error, String msg, long threadId, String threadName, long time) { - this.order = order; - this.error = error; - this.threadId = threadId; - this.threadName = threadName; - this.time = time; - this.msg = msg; - } - - /** - * @return Locally unique ID that is atomically incremented for each new error. - */ - public long getOrder() { - return order; - } - - /** - * @return Gets message that describe reason why error was suppressed. - */ - public String getMessage() { - return msg; - } - - /** - * @return Suppressed error. - */ - public VisorExceptionWrapper getError() { - return error; - } - - /** - * @return Gets thread ID. - */ - public long getThreadId() { - return threadId; - } - - /** - * @return Gets thread name. - */ - public String getThreadName() { - return threadName; - } - - /** - * @return Gets time. - */ - public long getTime() { - return time; - } - - /** {@inheritDoc} */ - @Override protected void writeExternalData(ObjectOutput out) throws IOException { - out.writeLong(order); - out.writeObject(error); - out.writeLong(threadId); - U.writeString(out, threadName); - out.writeLong(time); - U.writeString(out, msg); - } - - /** {@inheritDoc} */ - @Override protected void readExternalData(byte protoVer, ObjectInput in) throws IOException, ClassNotFoundException { - order = in.readLong(); - error = (VisorExceptionWrapper)in.readObject(); - threadId = in.readLong(); - threadName = U.readString(in); - time = in.readLong(); - msg = U.readString(in); - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorSuppressedError.class, this); - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorTransactionConfiguration.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorTransactionConfiguration.java deleted file mode 100644 index 1ac827a89e610..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorTransactionConfiguration.java +++ /dev/null @@ -1,159 +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.node; - -import java.io.IOException; -import java.io.ObjectInput; -import java.io.ObjectOutput; -import org.apache.ignite.configuration.TransactionConfiguration; -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.transactions.TransactionConcurrency; -import org.apache.ignite.transactions.TransactionIsolation; - -import static org.apache.ignite.internal.visor.util.VisorTaskUtils.compactClass; - -/** - * Data transfer object for transaction configuration. - */ -public class VisorTransactionConfiguration extends VisorDataTransferObject { - /** */ - private static final long serialVersionUID = 0L; - - /** Default cache concurrency. */ - private TransactionConcurrency dfltConcurrency; - - /** Default transaction isolation. */ - private TransactionIsolation dfltIsolation; - - /** Default transaction timeout. */ - private long dfltTimeout; - - /** Pessimistic tx log linger. */ - private int pessimisticTxLogLinger; - - /** Pessimistic tx log size. */ - private int pessimisticTxLogSize; - - /** Transaction manager factory. */ - private String txMgrFactory; - - /** - * Default constructor. - */ - public VisorTransactionConfiguration() { - // No-op. - } - - /** - * Whether to use JTA {@code javax.transaction.Synchronization} - * instead of {@code javax.transaction.xa.XAResource}. - */ - private boolean useJtaSync; - - /** - * Create data transfer object for transaction configuration. - * - * @param cfg Transaction configuration. - */ - public VisorTransactionConfiguration(TransactionConfiguration cfg) { - dfltConcurrency = cfg.getDefaultTxConcurrency(); - dfltIsolation = cfg.getDefaultTxIsolation(); - dfltTimeout = cfg.getDefaultTxTimeout(); - pessimisticTxLogLinger = cfg.getPessimisticTxLogLinger(); - pessimisticTxLogSize = cfg.getPessimisticTxLogSize(); - txMgrFactory = compactClass(cfg.getTxManagerFactory()); - useJtaSync = cfg.isUseJtaSynchronization(); - } - - /** - * @return Default cache transaction concurrency. - */ - public TransactionConcurrency getDefaultTxConcurrency() { - return dfltConcurrency; - } - - /** - * @return Default cache transaction isolation. - */ - public TransactionIsolation getDefaultTxIsolation() { - return dfltIsolation; - } - - /** - * @return Default transaction timeout. - */ - public long getDefaultTxTimeout() { - return dfltTimeout; - } - - /** - * @return Pessimistic log cleanup delay in milliseconds. - */ - public int getPessimisticTxLogLinger() { - return pessimisticTxLogLinger; - } - - /** - * @return Pessimistic transaction log size. - */ - public int getPessimisticTxLogSize() { - return pessimisticTxLogSize; - } - - /** - * @return Transaction manager factory. - */ - public String getTxManagerFactory() { - return txMgrFactory; - } - - /** - * @return Whether to use JTA {@code javax.transaction.Synchronization} - * instead of {@code javax.transaction.xa.XAResource}. - */ - public boolean isUseJtaSync() { - return useJtaSync; - } - - /** {@inheritDoc} */ - @Override protected void writeExternalData(ObjectOutput out) throws IOException { - U.writeEnum(out, dfltConcurrency); - U.writeEnum(out, dfltIsolation); - out.writeLong(dfltTimeout); - out.writeInt(pessimisticTxLogLinger); - out.writeInt(pessimisticTxLogSize); - U.writeString(out, txMgrFactory); - } - - /** {@inheritDoc} */ - @Override protected void readExternalData(byte protoVer, ObjectInput in) throws IOException, ClassNotFoundException { - dfltConcurrency = TransactionConcurrency.fromOrdinal(in.readByte()); - dfltIsolation = TransactionIsolation.fromOrdinal(in.readByte()); - dfltTimeout = in.readLong(); - pessimisticTxLogLinger = in.readInt(); - pessimisticTxLogSize = in.readInt(); - txMgrFactory = U.readString(in); - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorTransactionConfiguration.class, this); - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/query/VisorQueryCancelTask.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/query/VisorQueryCancelTask.java deleted file mode 100644 index 8bb764695a0b8..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/query/VisorQueryCancelTask.java +++ /dev/null @@ -1,74 +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.query; - -import java.util.Collections; -import java.util.List; -import org.apache.ignite.IgniteException; -import org.apache.ignite.compute.ComputeJobResult; -import org.apache.ignite.internal.processors.task.GridInternal; -import org.apache.ignite.internal.processors.task.GridVisorManagementTask; -import org.apache.ignite.internal.visor.VisorJob; -import org.apache.ignite.internal.visor.VisorOneNodeTask; -import org.jetbrains.annotations.Nullable; - -/** - * Task to cancel queries. - */ -@GridInternal -@GridVisorManagementTask -public class VisorQueryCancelTask extends VisorOneNodeTask { - /** */ - private static final long serialVersionUID = 0L; - - /** {@inheritDoc} */ - @Override protected VisorCancelQueriesJob job(VisorQueryCancelTaskArg arg) { - return new VisorCancelQueriesJob(arg, debug); - } - - /** {@inheritDoc} */ - @Nullable @Override protected Void reduce0(List results) throws IgniteException { - return null; - } - - /** - * Job to cancel queries on node. - */ - private static class VisorCancelQueriesJob extends VisorJob { - /** */ - private static final long serialVersionUID = 0L; - - /** - * Create job with specified argument. - * - * @param arg Job argument. - * @param debug Flag indicating whether debug information should be printed into node log. - */ - protected VisorCancelQueriesJob(@Nullable VisorQueryCancelTaskArg arg, boolean debug) { - super(arg, debug); - } - - /** {@inheritDoc} */ - @Override protected Void run(@Nullable VisorQueryCancelTaskArg arg) throws IgniteException { - ignite.context().query().cancelLocalQueries(Collections.singleton(arg.getQueryId())); - - return null; - } - } - -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/query/VisorQueryCancelTaskArg.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/query/VisorQueryCancelTaskArg.java deleted file mode 100644 index 887a11e8dfe26..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/query/VisorQueryCancelTaskArg.java +++ /dev/null @@ -1,71 +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.query; - -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.visor.VisorDataTransferObject; - -/** - * Arguments for task {@link VisorQueryCancelTask} - */ -public class VisorQueryCancelTaskArg extends VisorDataTransferObject { - /** */ - private static final long serialVersionUID = 0L; - - /** Query ID to cancel. */ - private long qryId; - - /** - * Default constructor. - */ - public VisorQueryCancelTaskArg() { - // No-op. - } - - /** - * @param qryId Query ID to cancel. - */ - public VisorQueryCancelTaskArg(long qryId) { - this.qryId = qryId; - } - - /** - * @return Query ID to cancel. - */ - public long getQueryId() { - return qryId; - } - - /** {@inheritDoc} */ - @Override protected void writeExternalData(ObjectOutput out) throws IOException { - out.writeLong(qryId); - } - - /** {@inheritDoc} */ - @Override protected void readExternalData(byte protoVer, ObjectInput in) throws IOException, ClassNotFoundException { - qryId = in.readLong(); - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorQueryCancelTaskArg.class, this); - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/query/VisorQueryCleanupTask.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/query/VisorQueryCleanupTask.java deleted file mode 100644 index e62393a5349bd..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/query/VisorQueryCleanupTask.java +++ /dev/null @@ -1,134 +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.query; - -import java.util.Collection; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.UUID; -import org.apache.ignite.cluster.ClusterNode; -import org.apache.ignite.compute.ComputeJob; -import org.apache.ignite.internal.processors.task.GridInternal; -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.VisorMultiNodeTask; -import org.apache.ignite.internal.visor.VisorTaskArgument; -import org.apache.ignite.internal.visor.util.VisorClusterGroupEmptyException; -import org.jetbrains.annotations.Nullable; - -import static org.apache.ignite.internal.visor.query.VisorQueryUtils.removeQueryHolder; -import static org.apache.ignite.internal.visor.util.VisorTaskUtils.log; -import static org.apache.ignite.internal.visor.util.VisorTaskUtils.logMapped; - -/** - * Task for cleanup not needed SCAN or SQL queries result futures from node local. - */ -@GridInternal -public class VisorQueryCleanupTask extends VisorMultiNodeTask { - /** */ - private static final long serialVersionUID = 0L; - - /** {@inheritDoc} */ - @Override protected VisorJob job(VisorQueryCleanupTaskArg arg) { - return null; - } - - /** {@inheritDoc} */ - @Override protected Map map0(List subgrid, - @Nullable VisorTaskArgument arg) { - Set nodeIds = taskArg.getQueryIds().keySet(); - - if (nodeIds.isEmpty()) - throw new VisorClusterGroupEmptyException("Nothing to clear. List with node IDs is empty!"); - - Map map = U.newHashMap(nodeIds.size()); - - try { - for (ClusterNode node : subgrid) - if (nodeIds.contains(node.id())) - map.put(new VisorQueryCleanupJob(taskArg.getQueryIds().get(node.id()), debug), node); - - if (map.isEmpty()) { - StringBuilder notFoundNodes = new StringBuilder(); - - for (UUID nid : nodeIds) - notFoundNodes.append((notFoundNodes.length() == 0) ? "" : ",").append(U.id8(nid)); - - throw new VisorClusterGroupEmptyException("Failed to clear query results. Nodes are not available: [" + - notFoundNodes + "]"); - } - - return map; - } - finally { - if (debug) - logMapped(ignite.log(), getClass(), map.values()); - } - } - - /** {@inheritDoc} */ - @Nullable @Override protected Void reduce0(List list) { - return null; - } - - /** - * Job for cleanup not needed SCAN or SQL queries result futures from node local. - */ - private static class VisorQueryCleanupJob extends VisorJob, Void> { - /** */ - private static final long serialVersionUID = 0L; - - /** - * Create job with specified argument. - * - * @param arg Job argument. - * @param debug Debug flag. - */ - protected VisorQueryCleanupJob(Collection arg, boolean debug) { - super(arg, debug); - } - - /** {@inheritDoc} */ - @Override protected Void run(Collection qryIds) { - long start = U.currentTimeMillis(); - - if (debug) { - start = log( - ignite.log(), - "Queries cancellation started: [" + String.join(", ", qryIds) + "]", - getClass(), - start); - } - - for (String qryId : qryIds) - removeQueryHolder(ignite, qryId); - - if (debug) - log(ignite.log(), "Queries cancellation finished", getClass(), start); - - return null; - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorQueryCleanupJob.class, this); - } - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/query/VisorQueryCleanupTaskArg.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/query/VisorQueryCleanupTaskArg.java deleted file mode 100644 index 878a6122ea70d..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/query/VisorQueryCleanupTaskArg.java +++ /dev/null @@ -1,75 +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.query; - -import java.io.IOException; -import java.io.ObjectInput; -import java.io.ObjectOutput; -import java.util.Collection; -import java.util.Map; -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.VisorDataTransferObject; - -/** - * Arguments for task {@link VisorQueryCleanupTask} - */ -public class VisorQueryCleanupTaskArg extends VisorDataTransferObject { - /** */ - private static final long serialVersionUID = 0L; - - /** Query IDs to cancel. */ - private Map> qryIds; - - /** - * Default constructor. - */ - public VisorQueryCleanupTaskArg() { - // No-op. - } - - /** - * @param qryIds Query IDs to cancel. - */ - public VisorQueryCleanupTaskArg(Map> qryIds) { - this.qryIds = qryIds; - } - - /** - * @return Query IDs to cancel. - */ - public Map> getQueryIds() { - return qryIds; - } - - /** {@inheritDoc} */ - @Override protected void writeExternalData(ObjectOutput out) throws IOException { - U.writeMap(out, qryIds); - } - - /** {@inheritDoc} */ - @Override protected void readExternalData(byte protoVer, ObjectInput in) throws IOException, ClassNotFoundException { - qryIds = U.readMap(in); - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorQueryCleanupTaskArg.class, this); - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/query/VisorQueryDetailMetrics.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/query/VisorQueryDetailMetrics.java deleted file mode 100644 index b74784514a5d6..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/query/VisorQueryDetailMetrics.java +++ /dev/null @@ -1,205 +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.query; - -import java.io.IOException; -import java.io.ObjectInput; -import java.io.ObjectOutput; -import org.apache.ignite.cache.query.QueryDetailMetrics; -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 cache query detail metrics. - */ -public class VisorQueryDetailMetrics extends VisorDataTransferObject { - /** */ - private static final long serialVersionUID = 0L; - - /** Query type. */ - private String qryType; - - /** Textual query representation. */ - private String qry; - - /** Cache name. */ - private String cache; - - /** Number of executions. */ - private int execs; - - /** Number of completions executions. */ - private int completions; - - /** Number of failures. */ - private int failures; - - /** Minimum time of execution. */ - private long minTime; - - /** Maximum time of execution. */ - private long maxTime; - - /** Average time of execution. */ - private double avgTime; - - /** Sum of execution time of completions time. */ - private long totalTime; - - /** Sum of execution time of completions time. */ - private long lastStartTime; - - /** - * Default constructor - */ - public VisorQueryDetailMetrics() { - // No-op. - } - - /** - * @param m Cache query metrics. - */ - public VisorQueryDetailMetrics(QueryDetailMetrics m) { - qryType = m.queryType(); - qry = m.query(); - cache = m.cache(); - - execs = m.executions(); - completions = m.completions(); - failures = m.failures(); - - minTime = m.minimumTime(); - maxTime = m.maximumTime(); - avgTime = m.averageTime(); - totalTime = m.totalTime(); - lastStartTime = m.lastStartTime(); - } - - /** - * @return Query type - */ - public String getQueryType() { - return qryType; - } - - /** - * @return Query type - */ - public String getQuery() { - return qry; - } - - /** - * @return Cache name where query was executed. - */ - public String getCache() { - return cache; - } - - /** - * @return Number of executions. - */ - public int getExecutions() { - return execs; - } - - /** - * @return Number of completed executions. - */ - public int getCompletions() { - return completions; - } - - /** - * @return Total number of times a query execution failed. - */ - public int getFailures() { - return failures; - } - - /** - * @return Minimum execution time of query. - */ - public long getMinimumTime() { - return minTime; - } - - /** - * @return Maximum execution time of query. - */ - public long getMaximumTime() { - return maxTime; - } - - /** - * @return Average execution time of query. - */ - public double getAverageTime() { - return avgTime; - } - - /** - * @return Total time of all query executions. - */ - public long getTotalTime() { - return totalTime; - } - - /** - * @return Latest time query was stared. - */ - public long getLastStartTime() { - return lastStartTime; - } - - /** {@inheritDoc} */ - @Override protected void writeExternalData(ObjectOutput out) throws IOException { - U.writeString(out, qryType); - U.writeString(out, qry); - U.writeString(out, cache); - out.writeInt(execs); - out.writeInt(completions); - out.writeInt(failures); - out.writeLong(minTime); - out.writeLong(maxTime); - out.writeDouble(avgTime); - out.writeLong(totalTime); - out.writeLong(lastStartTime); - } - - /** {@inheritDoc} */ - @Override protected void readExternalData(byte protoVer, ObjectInput in) throws IOException, ClassNotFoundException { - qryType = U.readString(in); - qry = U.readString(in); - cache = U.readString(in); - execs = in.readInt(); - completions = in.readInt(); - failures = in.readInt(); - minTime = in.readLong(); - maxTime = in.readLong(); - avgTime = in.readDouble(); - totalTime = in.readLong(); - lastStartTime = in.readLong(); - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorQueryDetailMetrics.class, this); - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/query/VisorQueryDetailMetricsCollectorTask.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/query/VisorQueryDetailMetricsCollectorTask.java deleted file mode 100644 index d45ddfa5f6cec..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/query/VisorQueryDetailMetricsCollectorTask.java +++ /dev/null @@ -1,145 +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.query; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import org.apache.ignite.IgniteException; -import org.apache.ignite.cache.query.QueryDetailMetrics; -import org.apache.ignite.compute.ComputeJobResult; -import org.apache.ignite.internal.processors.cache.GridCacheProcessor; -import org.apache.ignite.internal.processors.cache.IgniteInternalCache; -import org.apache.ignite.internal.processors.cache.query.GridCacheQueryDetailMetricsAdapter; -import org.apache.ignite.internal.processors.cache.query.GridCacheQueryDetailMetricsKey; -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.jetbrains.annotations.Nullable; - -import static org.apache.ignite.internal.processors.cache.GridCacheUtils.isSystemCache; - -/** - * Task to collect cache query metrics. - */ -@GridInternal -public class VisorQueryDetailMetricsCollectorTask extends VisorMultiNodeTask, Collection> { - /** */ - private static final long serialVersionUID = 0L; - - /** {@inheritDoc} */ - @Override protected VisorCacheQueryDetailMetricsCollectorJob job(VisorQueryDetailMetricsCollectorTaskArg arg) { - return new VisorCacheQueryDetailMetricsCollectorJob(arg, debug); - } - - /** {@inheritDoc} */ - @Nullable @Override protected Collection reduce0(List results) - throws IgniteException { - Map taskRes = new HashMap<>(); - - for (ComputeJobResult res : results) { - if (res.getException() != null) - throw res.getException(); - - Collection metrics = res.getData(); - - VisorCacheQueryDetailMetricsCollectorJob.aggregateMetrics(-1, taskRes, metrics); - } - - Collection aggMetrics = taskRes.values(); - - Collection res = new ArrayList<>(aggMetrics.size()); - - for (GridCacheQueryDetailMetricsAdapter m: aggMetrics) - res.add(new VisorQueryDetailMetrics(m)); - - return res; - } - - /** - * Job that will actually collect query metrics. - */ - private static class VisorCacheQueryDetailMetricsCollectorJob - extends VisorJob> { - /** */ - private static final long serialVersionUID = 0L; - - /** - * Create job with specified argument. - * - * @param arg Last time when metrics were collected. - * @param debug Debug flag. - */ - protected VisorCacheQueryDetailMetricsCollectorJob(@Nullable VisorQueryDetailMetricsCollectorTaskArg arg, boolean debug) { - super(arg, debug); - } - - /** - * @param since Time when metrics were collected last time. - * @param res Response. - * @param metrics Metrics. - */ - private static void aggregateMetrics(long since, Map res, Collection metrics) { - for (GridCacheQueryDetailMetricsAdapter m : metrics) { - if (m.lastStartTime() > since) { - GridCacheQueryDetailMetricsKey key = m.key(); - - GridCacheQueryDetailMetricsAdapter aggMetrics = res.get(key); - - res.put(key, aggMetrics == null ? m : aggMetrics.aggregate(m)); - } - } - } - - /** {@inheritDoc} */ - @Override protected Collection run( - @Nullable VisorQueryDetailMetricsCollectorTaskArg arg - ) throws IgniteException { - assert arg != null; - - GridCacheProcessor cacheProc = ignite.context().cache(); - - Collection cacheNames = cacheProc.cacheNames(); - - Map aggMetrics = new HashMap<>(); - - for (String cacheName : cacheNames) { - if (!isSystemCache(cacheName)) { - IgniteInternalCache cache = cacheProc.cache(cacheName); - - if (cache == null || !cache.context().started()) - continue; - - aggregateMetrics(arg.getSince(), aggMetrics, cache.context().queries().detailMetrics()); - } - } - - return new ArrayList<>(aggMetrics.values()); - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorCacheQueryDetailMetricsCollectorJob.class, this); - } - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/query/VisorQueryDetailMetricsCollectorTaskArg.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/query/VisorQueryDetailMetricsCollectorTaskArg.java deleted file mode 100644 index 5c769510010eb..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/query/VisorQueryDetailMetricsCollectorTaskArg.java +++ /dev/null @@ -1,71 +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.query; - -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.visor.VisorDataTransferObject; - -/** - * Arguments for task {@link VisorQueryDetailMetricsCollectorTask} - */ -public class VisorQueryDetailMetricsCollectorTaskArg extends VisorDataTransferObject { - /** */ - private static final long serialVersionUID = 0L; - - /** Time when metrics were collected last time. */ - private long since; - - /** - * Default constructor. - */ - public VisorQueryDetailMetricsCollectorTaskArg() { - // No-op. - } - - /** - * @param since Time when metrics were collected last time. - */ - public VisorQueryDetailMetricsCollectorTaskArg(long since) { - this.since = since; - } - - /** - * @return Time when metrics were collected last time. - */ - public long getSince() { - return since; - } - - /** {@inheritDoc} */ - @Override protected void writeExternalData(ObjectOutput out) throws IOException { - out.writeLong(since); - } - - /** {@inheritDoc} */ - @Override protected void readExternalData(byte protoVer, ObjectInput in) throws IOException, ClassNotFoundException { - since = in.readLong(); - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorQueryDetailMetricsCollectorTaskArg.class, this); - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/query/VisorQueryFetchFirstPageTask.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/query/VisorQueryFetchFirstPageTask.java deleted file mode 100644 index 98d4801c79e58..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/query/VisorQueryFetchFirstPageTask.java +++ /dev/null @@ -1,107 +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.query; - -import java.util.Iterator; -import java.util.List; -import org.apache.ignite.internal.processors.task.GridInternal; -import org.apache.ignite.internal.util.typedef.internal.S; -import org.apache.ignite.internal.util.typedef.internal.U; -import org.apache.ignite.internal.visor.VisorEither; -import org.apache.ignite.internal.visor.VisorJob; -import org.apache.ignite.internal.visor.VisorOneNodeTask; -import org.apache.ignite.internal.visor.util.VisorExceptionWrapper; - -import static org.apache.ignite.internal.visor.query.VisorQueryUtils.fetchQueryRows; -import static org.apache.ignite.internal.visor.query.VisorQueryUtils.getQueryHolder; -import static org.apache.ignite.internal.visor.query.VisorQueryUtils.removeQueryHolder; -import static org.apache.ignite.internal.visor.util.VisorTaskUtils.log; - -/** - * Task for check a query execution and receiving first page of query result. - */ -@GridInternal -public class VisorQueryFetchFirstPageTask extends VisorOneNodeTask> { - /** */ - private static final long serialVersionUID = 0L; - - /** {@inheritDoc} */ - @Override protected VisorQueryFetchFirstPageJob job(VisorQueryNextPageTaskArg arg) { - return new VisorQueryFetchFirstPageJob(arg, debug); - } - - /** - * Job for collecting first page previously executed SQL or SCAN query. - */ - private static class VisorQueryFetchFirstPageJob extends VisorJob> { - /** */ - private static final long serialVersionUID = 0L; - - /** - * Create job with specified argument. - * - * @param arg Job argument. - * @param debug Debug flag. - */ - private VisorQueryFetchFirstPageJob(VisorQueryNextPageTaskArg arg, boolean debug) { - super(arg, debug); - } - - /** {@inheritDoc} */ - @Override protected VisorEither run(VisorQueryNextPageTaskArg arg) { - String qryId = arg.getQueryId(); - - long start = U.currentTimeMillis(); - - if (debug) - start = log(ignite.log(), "Fetch query first page started: " + qryId, getClass(), start); - - VisorQueryHolder holder = getQueryHolder(ignite, qryId); - - if (holder.getErr() != null) - return new VisorEither<>(new VisorExceptionWrapper(holder.getErr())); - - List rows = null; - List cols = holder.getColumns(); - - boolean hasMore = cols == null; - - if (cols != null) { - Iterator itr = holder.getIterator(); - rows = fetchQueryRows(itr, qryId, arg.getPageSize()); - hasMore = itr.hasNext(); - } - - if (hasMore) - holder.setAccessed(true); - else - removeQueryHolder(ignite, qryId); - - if (debug) - log(ignite.log(), "Fetch query first page finished: " + qryId, getClass(), start); - - return new VisorEither<>( - new VisorQueryResult(ignite.localNode().id(), qryId, cols, rows, hasMore, holder.duration())); - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorQueryFetchFirstPageJob.class, this); - } - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/query/VisorQueryField.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/query/VisorQueryField.java deleted file mode 100644 index ad84dda2bf2be..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/query/VisorQueryField.java +++ /dev/null @@ -1,132 +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.query; - -import java.io.IOException; -import java.io.ObjectInput; -import java.io.ObjectOutput; -import org.apache.ignite.internal.util.typedef.F; -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 query field type description. - */ -public class VisorQueryField extends VisorDataTransferObject { - /** */ - private static final long serialVersionUID = 0L; - - /** Schema name. */ - private String schemaName; - - /** Type name. */ - private String typeName; - - /** Field name. */ - private String fieldName; - - /** Field type name. */ - private String fieldTypeName; - - /** - * Default constructor. - */ - public VisorQueryField() { - // No-op. - } - - /** - * Create data transfer object with given parameters. - * - * @param schemaName Schema name. - * @param typeName Type name. - * @param fieldName Name. - * @param fieldTypeName Type. - */ - public VisorQueryField(String schemaName, String typeName, String fieldName, String fieldTypeName) { - this.schemaName = schemaName; - this.typeName = typeName; - this.fieldName = fieldName; - this.fieldTypeName = fieldTypeName; - } - - /** - * @return Schema name. - */ - public String getSchemaName() { - return schemaName; - } - - /** - * @return Type name. - */ - public String getTypeName() { - return typeName; - } - - /** - * @return Field name. - */ - public String getFieldName() { - return fieldName; - } - - /** - * @return Field type name. - */ - public String getFieldTypeName() { - return fieldTypeName; - } - - /** - * @param schema If {@code true} then add schema name to full name. - * @return Fully qualified field name with type name and schema name. - */ - public String getFullName(boolean schema) { - if (!F.isEmpty(typeName)) { - if (schema && !F.isEmpty(schemaName)) - return schemaName + "." + typeName + "." + fieldName; - - return typeName + "." + fieldName; - } - - return fieldName; - } - - /** {@inheritDoc} */ - @Override protected void writeExternalData(ObjectOutput out) throws IOException { - U.writeString(out, schemaName); - U.writeString(out, typeName); - U.writeString(out, fieldName); - U.writeString(out, fieldTypeName); - } - - /** {@inheritDoc} */ - @Override protected void readExternalData(byte protoVer, ObjectInput in) throws IOException, ClassNotFoundException { - schemaName = U.readString(in); - typeName = U.readString(in); - fieldName = U.readString(in); - fieldTypeName = U.readString(in); - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorQueryField.class, this); - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/query/VisorQueryHolder.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/query/VisorQueryHolder.java deleted file mode 100644 index af54f27df5c05..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/query/VisorQueryHolder.java +++ /dev/null @@ -1,171 +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.query; - -import java.util.Iterator; -import java.util.List; -import java.util.UUID; -import org.apache.ignite.cache.query.QueryCursor; -import org.apache.ignite.internal.processors.query.GridQueryCancel; - -/** - * Holds identify information of executing query and its result. - */ -public class VisorQueryHolder implements AutoCloseable { - /** Prefix for node local key for SQL queries. */ - private static final String SQL_QRY_PREFIX = "VISOR_SQL_QUERY"; - - /** Prefix for node local key for SCAN queries. */ - private static final String SCAN_QRY_PREFIX = "VISOR_SCAN_QUERY"; - - /** Query ID for extraction query data result. */ - private final String qryId; - - /** Cancel query object. */ - private final GridQueryCancel cancel; - - /** Query column descriptors. */ - private volatile List cols; - - /** Error in process of query result receiving. */ - private volatile Throwable err; - - /** Query duration in ms. */ - private volatile long duration; - - /** Flag indicating that this cursor was read from last check. */ - private volatile boolean accessed; - - /** Query cursor. */ - private volatile QueryCursor cur; - - /** Result set iterator. */ - private volatile Iterator itr; - - /** - * @param qryId Query ID. - * @return {@code true} if holder contains SQL query. - */ - public static boolean isSqlQuery(String qryId) { - return qryId.startsWith(SQL_QRY_PREFIX); - } - - /** - * Constructor. - * - * @param sqlQry Flag indicating that holder contains SQL or SCAN query. - * @param cur Query cursor. - * @param cancel Cancel object. - */ - VisorQueryHolder(boolean sqlQry, QueryCursor cur, GridQueryCancel cancel) { - this.cur = cur; - this.cancel = cancel; - - // Generate query ID to store query cursor in node local storage. - qryId = (sqlQry ? SQL_QRY_PREFIX : SCAN_QRY_PREFIX) + "-" + UUID.randomUUID(); - } - - /** - * @return Query ID for extraction query data result. - */ - public String getQueryID() { - return qryId; - } - - /** - * @return Result set iterator. - */ - public synchronized Iterator getIterator() { - assert cur != null; - - if (itr == null) - itr = cur.iterator(); - - return itr; - } - - /** - * @return Query column descriptors. - */ - public List getColumns() { - return cols; - } - - /** - * Complete query execution. - * - * @param cur Query cursor. - * @param duration Duration of query execution. - * @param cols Query column descriptors. - */ - public void complete(QueryCursor cur, long duration, List cols) { - this.cur = cur; - this.duration = duration; - this.cols = cols; - this.accessed = false; - } - - /** {@inheritDoc} */ - @Override public void close() { - if (cur != null) - cur.close(); - - if (cancel != null) - cancel.cancel(); - } - - /** - * @return Error in process of query result receiving. - */ - public Throwable getErr() { - return err; - } - - /** - * Set error caught during query execution. - * - * @param err Error caught during query execution. - */ - public void setError(Throwable err) { - this.err = err; - - if (cur != null) - cur.close(); - } - - /** - * @return Flag indicating that this future was read from last check.. - */ - public boolean isAccessed() { - return accessed; - } - - /** - * @param accessed New accessed. - */ - public void setAccessed(boolean accessed) { - this.accessed = accessed; - } - - /** - * @return Duration of query execution. - */ - public long duration() { - return duration; - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/query/VisorQueryMetrics.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/query/VisorQueryMetrics.java deleted file mode 100644 index f878ab63e7e47..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/query/VisorQueryMetrics.java +++ /dev/null @@ -1,125 +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.query; - -import java.io.IOException; -import java.io.ObjectInput; -import java.io.ObjectOutput; -import org.apache.ignite.cache.query.QueryMetrics; -import org.apache.ignite.internal.util.typedef.internal.S; -import org.apache.ignite.internal.visor.VisorDataTransferObject; - -/** - * Data transfer object for cache query metrics. - */ -public class VisorQueryMetrics extends VisorDataTransferObject { - /** */ - private static final long serialVersionUID = 0L; - - /** Minimum execution time of query. */ - private long minTime; - - /** Maximum execution time of query. */ - private long maxTime; - - /** Average execution time of query. */ - private double avgTime; - - /** Number of executions. */ - private int execs; - - /** Total number of times a query execution failed. */ - private int fails; - - /** - * Default constructor. - */ - public VisorQueryMetrics() { - // No-op. - } - - /** - * Create data transfer object for given cache metrics. - * @param m Cache query metrics. - */ - public VisorQueryMetrics(QueryMetrics m) { - minTime = m.minimumTime(); - maxTime = m.maximumTime(); - avgTime = m.averageTime(); - execs = m.executions(); - fails = m.fails(); - } - - /** - * @return Minimum execution time of query. - */ - public long getMinimumTime() { - return minTime; - } - - /** - * @return Maximum execution time of query. - */ - public long getMaximumTime() { - return maxTime; - } - - /** - * @return Average execution time of query. - */ - public double getAverageTime() { - return avgTime; - } - - /** - * @return Number of executions. - */ - public int getExecutions() { - return execs; - } - - /** - * @return Total number of times a query execution failed. - */ - public int getFailures() { - return fails; - } - - /** {@inheritDoc} */ - @Override protected void writeExternalData(ObjectOutput out) throws IOException { - out.writeLong(minTime); - out.writeLong(maxTime); - out.writeDouble(avgTime); - out.writeInt(execs); - out.writeInt(fails); - } - - /** {@inheritDoc} */ - @Override protected void readExternalData(byte protoVer, ObjectInput in) throws IOException, ClassNotFoundException { - minTime = in.readLong(); - maxTime = in.readLong(); - avgTime = in.readDouble(); - execs = in.readInt(); - fails = in.readInt(); - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorQueryMetrics.class, this); - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/query/VisorQueryNextPageTask.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/query/VisorQueryNextPageTask.java deleted file mode 100644 index dc7b09fc53b66..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/query/VisorQueryNextPageTask.java +++ /dev/null @@ -1,91 +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.query; - -import java.util.Iterator; -import java.util.List; -import org.apache.ignite.internal.processors.task.GridInternal; -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 static org.apache.ignite.internal.visor.query.VisorQueryUtils.getQueryHolder; -import static org.apache.ignite.internal.visor.query.VisorQueryUtils.removeQueryHolder; - -/** - * Task for collecting next page previously executed SQL or SCAN query. - */ -@GridInternal -public class VisorQueryNextPageTask extends VisorOneNodeTask { - /** */ - private static final long serialVersionUID = 0L; - - /** {@inheritDoc} */ - @Override protected VisorQueryNextPageJob job(VisorQueryNextPageTaskArg arg) { - return new VisorQueryNextPageJob(arg, debug); - } - - /** - * Job for collecting next page previously executed SQL or SCAN query. - */ - private static class VisorQueryNextPageJob extends VisorJob { - /** */ - private static final long serialVersionUID = 0L; - - /** - * Create job with specified argument. - * - * @param arg Job argument. - * @param debug Debug flag. - */ - private VisorQueryNextPageJob(VisorQueryNextPageTaskArg arg, boolean debug) { - super(arg, debug); - } - - /** {@inheritDoc} */ - @Override protected VisorQueryResult run(VisorQueryNextPageTaskArg arg) { - long start = U.currentTimeMillis(); - - String qryId = arg.getQueryId(); - - VisorQueryHolder holder = getQueryHolder(ignite, qryId); - - Iterator itr = holder.getIterator(); - - List nextRows = VisorQueryHolder.isSqlQuery(qryId) - ? VisorQueryUtils.fetchSqlQueryRows(itr, arg.getPageSize()) - : VisorQueryUtils.fetchScanQueryRows(itr, arg.getPageSize()); - - boolean hasMore = itr.hasNext(); - - if (hasMore) - holder.setAccessed(true); - else - removeQueryHolder(ignite, qryId); - - return new VisorQueryResult(ignite.localNode().id(), qryId, null, nextRows, hasMore, - U.currentTimeMillis() - start); - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorQueryNextPageJob.class, this); - } - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/query/VisorQueryNextPageTaskArg.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/query/VisorQueryNextPageTaskArg.java deleted file mode 100644 index d0f62b9363a48..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/query/VisorQueryNextPageTaskArg.java +++ /dev/null @@ -1,86 +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.query; - -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; - -/** - * Arguments for {@link VisorQueryNextPageTask}. - */ -public class VisorQueryNextPageTaskArg extends VisorDataTransferObject { - /** */ - private static final long serialVersionUID = 0L; - - /** ID of query execution. */ - private String qryId; - - /** Number of rows to load. */ - private int pageSize; - - /** - * Default constructor. - */ - public VisorQueryNextPageTaskArg() { - // No-op. - } - - /** - * @param qryId ID of query execution. - * @param pageSize Number of rows to load. - */ - public VisorQueryNextPageTaskArg(String qryId, int pageSize) { - this.qryId = qryId; - this.pageSize = pageSize; - } - - /** - * @return ID of query execution. - */ - public String getQueryId() { - return qryId; - } - - /** - * @return Number of rows to load. - */ - public int getPageSize() { - return pageSize; - } - - /** {@inheritDoc} */ - @Override protected void writeExternalData(ObjectOutput out) throws IOException { - U.writeString(out, qryId); - out.writeInt(pageSize); - } - - /** {@inheritDoc} */ - @Override protected void readExternalData(byte protoVer, ObjectInput in) throws IOException, ClassNotFoundException { - qryId = U.readString(in); - pageSize = in.readInt(); - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorQueryNextPageTaskArg.class, this); - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/query/VisorQueryPingTask.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/query/VisorQueryPingTask.java deleted file mode 100644 index b7d42006b6c1a..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/query/VisorQueryPingTask.java +++ /dev/null @@ -1,88 +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.query; - -import org.apache.ignite.internal.processors.task.GridInternal; -import org.apache.ignite.internal.util.typedef.internal.S; -import org.apache.ignite.internal.util.typedef.internal.U; -import org.apache.ignite.internal.visor.VisorEither; -import org.apache.ignite.internal.visor.VisorJob; -import org.apache.ignite.internal.visor.VisorOneNodeTask; -import org.apache.ignite.internal.visor.util.VisorExceptionWrapper; - -import static org.apache.ignite.internal.visor.query.VisorQueryUtils.getQueryHolder; -import static org.apache.ignite.internal.visor.util.VisorTaskUtils.log; - -/** - * Task for inform a node about awaiting of query result from Web console. - */ -@GridInternal -public class VisorQueryPingTask extends VisorOneNodeTask> { - /** */ - private static final long serialVersionUID = 0L; - - /** {@inheritDoc} */ - @Override protected VisorQueryFetchFirstPageJob job(VisorQueryNextPageTaskArg arg) { - return new VisorQueryFetchFirstPageJob(arg, debug); - } - - /** - * Job for inform a node about awaiting of query result from Web console. - */ - private static class VisorQueryFetchFirstPageJob extends VisorJob> { - /** */ - private static final long serialVersionUID = 0L; - - /** - * Create job with specified argument. - * - * @param arg Job argument. - * @param debug Debug flag. - */ - private VisorQueryFetchFirstPageJob(VisorQueryNextPageTaskArg arg, boolean debug) { - super(arg, debug); - } - - /** {@inheritDoc} */ - @Override protected VisorEither run(VisorQueryNextPageTaskArg arg) { - String qryId = arg.getQueryId(); - - long start = U.currentTimeMillis(); - - if (debug) - start = log(ignite.log(), "Ping of query started: " + qryId, getClass(), start); - - VisorQueryHolder holder = getQueryHolder(ignite, qryId); - - if (holder.getErr() != null) - return new VisorEither<>(new VisorExceptionWrapper(holder.getErr())); - - holder.setAccessed(true); - - if (debug) - log(ignite.log(), "Ping of query finished: " + qryId, getClass(), start); - - return new VisorEither<>(new VisorQueryPingTaskResult()); - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorQueryFetchFirstPageJob.class, this); - } - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/query/VisorQueryPingTaskResult.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/query/VisorQueryPingTaskResult.java deleted file mode 100644 index 540dd14f1286e..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/query/VisorQueryPingTaskResult.java +++ /dev/null @@ -1,50 +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.query; - -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.visor.VisorDataTransferObject; - -/** - * Result for cache query ping tasks. - */ -public class VisorQueryPingTaskResult extends VisorDataTransferObject { - /** */ - private static final long serialVersionUID = 0L; - - /** - * Default constructor. - */ - public VisorQueryPingTaskResult() { - // No-op. - } - - /** {@inheritDoc} */ - @Override protected void writeExternalData(ObjectOutput out) throws IOException {} - - /** {@inheritDoc} */ - @Override protected void readExternalData(byte protoVer, ObjectInput in) throws IOException, ClassNotFoundException {} - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorQueryPingTaskResult.class, this); - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/query/VisorQueryResetDetailMetricsTask.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/query/VisorQueryResetDetailMetricsTask.java deleted file mode 100644 index a0da7972c44b4..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/query/VisorQueryResetDetailMetricsTask.java +++ /dev/null @@ -1,73 +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.query; - -import org.apache.ignite.IgniteCache; -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.VisorOneNodeTask; - -/** - * Reset query detail metrics. - */ -@GridInternal -public class VisorQueryResetDetailMetricsTask extends VisorOneNodeTask { - /** */ - private static final long serialVersionUID = 0L; - - /** {@inheritDoc} */ - @Override protected VisorCacheResetQueryDetailMetricsJob job(Void arg) { - return new VisorCacheResetQueryDetailMetricsJob(arg, debug); - } - - /** - * Job that reset query detail metrics. - */ - private static class VisorCacheResetQueryDetailMetricsJob extends VisorJob { - /** */ - private static final long serialVersionUID = 0L; - - /** - * @param arg Task argument. - * @param debug Debug flag. - */ - private VisorCacheResetQueryDetailMetricsJob(Void arg, boolean debug) { - super(arg, debug); - } - - /** {@inheritDoc} */ - @Override protected Void run(Void arg) { - for (String cacheName : ignite.cacheNames()) { - IgniteCache cache = ignite.cache(cacheName); - - if (cache == null) - throw new IllegalStateException("Failed to find cache for name: " + cacheName); - - cache.resetQueryDetailMetrics(); - } - - return null; - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorCacheResetQueryDetailMetricsJob.class, this); - } - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/query/VisorQueryResetMetricsTask.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/query/VisorQueryResetMetricsTask.java deleted file mode 100644 index a339f8d790474..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/query/VisorQueryResetMetricsTask.java +++ /dev/null @@ -1,75 +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.query; - -import org.apache.ignite.IgniteCache; -import org.apache.ignite.internal.processors.task.GridInternal; -import org.apache.ignite.internal.processors.task.GridVisorManagementTask; -import org.apache.ignite.internal.util.typedef.internal.S; -import org.apache.ignite.internal.visor.VisorJob; -import org.apache.ignite.internal.visor.VisorOneNodeTask; - -/** - * Reset compute grid query metrics. - */ -@GridInternal -@GridVisorManagementTask -public class VisorQueryResetMetricsTask extends VisorOneNodeTask { - /** */ - private static final long serialVersionUID = 0L; - - /** {@inheritDoc} */ - @Override protected VisorQueryResetMetricsJob job(VisorQueryResetMetricsTaskArg arg) { - return new VisorQueryResetMetricsJob(arg, debug); - } - - /** - * Job that reset cache query metrics. - */ - private static class VisorQueryResetMetricsJob extends VisorJob { - /** */ - private static final long serialVersionUID = 0L; - - /** - * @param arg Cache name to reset query metrics for. - * @param debug Debug flag. - */ - private VisorQueryResetMetricsJob(VisorQueryResetMetricsTaskArg arg, boolean debug) { - super(arg, debug); - } - - /** {@inheritDoc} */ - @Override protected Void run(VisorQueryResetMetricsTaskArg arg) { - String cacheName = arg.getCacheName(); - - IgniteCache cache = ignite.cache(cacheName); - - if (cache == null) - throw new IllegalStateException("Failed to find cache for name: " + cacheName); - - cache.resetQueryMetrics(); - - return null; - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorQueryResetMetricsJob.class, this); - } - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/query/VisorQueryResetMetricsTaskArg.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/query/VisorQueryResetMetricsTaskArg.java deleted file mode 100644 index 8faa43bbd25d2..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/query/VisorQueryResetMetricsTaskArg.java +++ /dev/null @@ -1,72 +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.query; - -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; - -/** - * Argument for {@link VisorQueryResetMetricsTask}. - */ -public class VisorQueryResetMetricsTaskArg extends VisorDataTransferObject { - /** */ - private static final long serialVersionUID = 0L; - - /** Cache name. */ - private String cacheName; - - /** - * Default constructor. - */ - public VisorQueryResetMetricsTaskArg() { - // No-op. - } - - /** - * @param cacheName Cache name. - */ - public VisorQueryResetMetricsTaskArg(String cacheName) { - this.cacheName = cacheName; - } - - /** - * @return Cache name. - */ - public String getCacheName() { - return cacheName; - } - - /** {@inheritDoc} */ - @Override protected void writeExternalData(ObjectOutput out) throws IOException { - U.writeString(out, cacheName); - } - - /** {@inheritDoc} */ - @Override protected void readExternalData(byte protoVer, ObjectInput in) throws IOException, ClassNotFoundException { - cacheName = U.readString(in); - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorQueryResetMetricsTaskArg.class, this); - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/query/VisorQueryResult.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/query/VisorQueryResult.java deleted file mode 100644 index f7beae2cfefbe..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/query/VisorQueryResult.java +++ /dev/null @@ -1,152 +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.query; - -import java.io.IOException; -import java.io.ObjectInput; -import java.io.ObjectOutput; -import java.util.Collection; -import java.util.List; -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.VisorDataTransferObject; - -/** - * Result for cache query tasks. - */ -public class VisorQueryResult extends VisorDataTransferObject { - /** */ - private static final long serialVersionUID = 0L; - - /** Node where query executed. */ - private UUID resNodeId; - - /** Query ID to store in node local. */ - private String qryId; - - /** Query columns descriptors. */ - private List cols; - - /** Rows fetched from query. */ - private List rows; - - /** Whether query has more rows to fetch. */ - private boolean hasMore; - - /** Query duration */ - private long duration; - - /** - * Default constructor. - */ - public VisorQueryResult() { - // No-op. - } - - /** - * @param resNodeId Node where query executed. - * @param qryId Query ID for future extraction in nextPage() access. - * @param cols Columns descriptors. - * @param rows Rows fetched from query. - * @param hasMore Whether query has more rows to fetch. - * @param duration Query duration. - */ - public VisorQueryResult( - UUID resNodeId, - String qryId, - List cols, - List rows, - boolean hasMore, - long duration - ) { - this.resNodeId = resNodeId; - this.qryId = qryId; - this.cols = cols; - this.rows = rows; - this.hasMore = hasMore; - this.duration = duration; - } - - /** - * @return Response node id. - */ - public UUID getResponseNodeId() { - return resNodeId; - } - - /** - * @return Query id. - */ - public String getQueryId() { - return qryId; - } - - /** - * @return Columns. - */ - public Collection getColumns() { - return cols; - } - - /** - * @return Rows fetched from query. - */ - public List getRows() { - return rows; - } - - /** - * @return Whether query has more rows to fetch. - */ - public boolean isHasMore() { - return hasMore; - } - - /** - * @return Duration of next page fetching. - */ - public long getDuration() { - return duration; - } - - /** {@inheritDoc} */ - @Override protected void writeExternalData(ObjectOutput out) throws IOException { - U.writeUuid(out, resNodeId); - U.writeString(out, qryId); - U.writeCollection(out, cols); - U.writeCollection(out, rows); - out.writeBoolean(hasMore); - out.writeLong(duration); - } - - /** {@inheritDoc} */ - @Override protected void readExternalData(byte protoVer, ObjectInput in) throws IOException, ClassNotFoundException { - resNodeId = U.readUuid(in); - qryId = U.readString(in); - cols = U.readList(in); - rows = U.readList(in); - hasMore = in.readBoolean(); - duration = in.readLong(); - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorQueryResult.class, this); - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/query/VisorQueryScanRegexFilter.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/query/VisorQueryScanRegexFilter.java deleted file mode 100644 index 3c200b2faf581..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/query/VisorQueryScanRegexFilter.java +++ /dev/null @@ -1,60 +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.query; - -import java.util.regex.Pattern; -import org.apache.ignite.binary.BinaryObject; -import org.apache.ignite.lang.IgniteBiPredicate; - -/** - * Filter scan results by specified substring in string presentation of key or value. - */ -public class VisorQueryScanRegexFilter implements IgniteBiPredicate { - /** */ - private static final long serialVersionUID = 0L; - - /** Regex pattern to search data. */ - private final Pattern ptrn; - - /** - * Create filter instance. - * - * @param caseSensitive Case sensitive flag. - * @param regex Regex search flag. - * @param ptrn String to search in string presentation of key or value. - */ - public VisorQueryScanRegexFilter(boolean caseSensitive, boolean regex, String ptrn) { - int flags = caseSensitive ? 0 : Pattern.CASE_INSENSITIVE; - - this.ptrn = Pattern.compile(regex ? ptrn : ".*?" + Pattern.quote(ptrn) + ".*?", flags); - } - - /** - * Check that key or value contains specified string. - * - * @param key Key object. - * @param val Value object. - * @return {@code true} when string presentation of key or value contain specified string. - */ - @Override public boolean apply(Object key, Object val) { - String k = key instanceof BinaryObject ? VisorQueryUtils.binaryToString((BinaryObject)key) : key.toString(); - String v = val instanceof BinaryObject ? VisorQueryUtils.binaryToString((BinaryObject)val) : val.toString(); - - return ptrn.matcher(k).find() || ptrn.matcher(v).find(); - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/query/VisorQueryTask.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/query/VisorQueryTask.java deleted file mode 100644 index 88a1c8d1e3cee..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/query/VisorQueryTask.java +++ /dev/null @@ -1,91 +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.query; - -import java.util.Map; -import java.util.UUID; -import org.apache.ignite.internal.processors.query.GridQueryCancel; -import org.apache.ignite.internal.processors.task.GridInternal; -import org.apache.ignite.internal.processors.task.GridVisorManagementTask; -import org.apache.ignite.internal.util.typedef.internal.S; -import org.apache.ignite.internal.visor.VisorEither; -import org.apache.ignite.internal.visor.VisorJob; -import org.apache.ignite.internal.visor.VisorOneNodeTask; -import org.apache.ignite.internal.visor.util.VisorExceptionWrapper; - -import static org.apache.ignite.internal.visor.query.VisorQueryUtils.scheduleQueryStart; - -/** - * Task for execute SQL fields query and get first page of results. - */ -@GridInternal -@GridVisorManagementTask -public class VisorQueryTask extends VisorOneNodeTask> { - /** */ - private static final long serialVersionUID = 0L; - - /** {@inheritDoc} */ - @Override protected VisorQueryJob job(VisorQueryTaskArg arg) { - return new VisorQueryJob(arg, debug); - } - - /** - * Job for execute SCAN or SQL query and get first page of results. - */ - private static class VisorQueryJob extends VisorJob> { - /** */ - private static final long serialVersionUID = 0L; - - /** - * Create job with specified argument. - * - * @param arg Job argument. - * @param debug Debug flag. - */ - private VisorQueryJob(VisorQueryTaskArg arg, boolean debug) { - super(arg, debug); - } - - /** {@inheritDoc} */ - @Override protected VisorEither run(final VisorQueryTaskArg arg) { - try { - UUID nid = ignite.localNode().id(); - - GridQueryCancel cancel = new GridQueryCancel(); - - Map storage = ignite.cluster().nodeLocalMap(); - - VisorQueryHolder holder = new VisorQueryHolder(true, null, cancel); - - storage.put(holder.getQueryID(), holder); - - scheduleQueryStart(ignite, holder, arg, cancel); - - return new VisorEither<>(new VisorQueryResult(nid, holder.getQueryID(), null, null, false, 0)); - } - catch (Throwable e) { - return new VisorEither<>(new VisorExceptionWrapper(e)); - } - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorQueryJob.class, this); - } - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/query/VisorQueryTaskArg.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/query/VisorQueryTaskArg.java deleted file mode 100644 index 5220b02632bb1..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/query/VisorQueryTaskArg.java +++ /dev/null @@ -1,249 +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.query; - -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; - -/** - * Arguments for {@link VisorQueryTask}. - */ -public class VisorQueryTaskArg extends VisorDataTransferObject { - /** */ - private static final long serialVersionUID = 0L; - - /** Cache name for query. */ - private String cacheName; - - /** Query text. */ - private String qryTxt; - - /** Distributed joins enabled flag. */ - private boolean distributedJoins; - - /** Enforce join order flag. */ - private boolean enforceJoinOrder; - - /** Query contains only replicated tables flag.*/ - private boolean replicatedOnly; - - /** Flag whether to execute query locally. */ - private boolean loc; - - /** Result batch size. */ - private int pageSize; - - /** Lazy query execution flag */ - private boolean lazy; - - /** Collocation flag. */ - private boolean collocated; - - /** - * Default constructor. - */ - public VisorQueryTaskArg() { - // No-op. - } - - /** - * @param cacheName Cache name for query. - * @param qryTxt Query text. - * @param distributedJoins If {@code true} then distributed joins enabled. - * @param enforceJoinOrder If {@code true} then enforce join order. - * @param replicatedOnly {@code true} then query contains only replicated tables. - * @param loc Flag whether to execute query locally. - * @param pageSize Result batch size. - */ - public VisorQueryTaskArg( - String cacheName, - String qryTxt, - boolean distributedJoins, - boolean enforceJoinOrder, - boolean replicatedOnly, - boolean loc, - int pageSize - ) { - this(cacheName, qryTxt, distributedJoins, enforceJoinOrder, replicatedOnly, loc, pageSize, false, false); - } - - /** - * @param cacheName Cache name for query. - * @param qryTxt Query text. - * @param distributedJoins If {@code true} then distributed joins enabled. - * @param enforceJoinOrder If {@code true} then enforce join order. - * @param replicatedOnly {@code true} then query contains only replicated tables. - * @param loc Flag whether to execute query locally. - * @param pageSize Result batch size. - * @param lazy Lazy query execution flag. - */ - public VisorQueryTaskArg( - String cacheName, - String qryTxt, - boolean distributedJoins, - boolean enforceJoinOrder, - boolean replicatedOnly, - boolean loc, - int pageSize, - boolean lazy - ) { - this(cacheName, qryTxt, distributedJoins, enforceJoinOrder, replicatedOnly, loc, pageSize, lazy, false); - } - - /** - * @param cacheName Cache name for query. - * @param qryTxt Query text. - * @param distributedJoins If {@code true} then distributed joins enabled. - * @param enforceJoinOrder If {@code true} then enforce join order. - * @param replicatedOnly {@code true} then query contains only replicated tables. - * @param loc Flag whether to execute query locally. - * @param pageSize Result batch size. - * @param lazy Lazy query execution flag. - * @param collocated Collocation flag. - */ - public VisorQueryTaskArg( - String cacheName, - String qryTxt, - boolean distributedJoins, - boolean enforceJoinOrder, - boolean replicatedOnly, - boolean loc, - int pageSize, - boolean lazy, - boolean collocated - ) { - this.cacheName = cacheName; - this.qryTxt = qryTxt; - this.distributedJoins = distributedJoins; - this.enforceJoinOrder = enforceJoinOrder; - this.replicatedOnly = replicatedOnly; - this.loc = loc; - this.pageSize = pageSize; - this.lazy = lazy; - this.collocated = collocated; - } - - /** - * @return Cache name. - */ - public String getCacheName() { - return cacheName; - } - - /** - * @return Query txt. - */ - public String getQueryText() { - return qryTxt; - } - - /** - * @return Distributed joins enabled flag. - */ - public boolean isDistributedJoins() { - return distributedJoins; - } - - /** - * @return Enforce join order flag. - */ - public boolean isEnforceJoinOrder() { - return enforceJoinOrder; - } - - /** - * @return {@code true} If the query contains only replicated tables. - */ - public boolean isReplicatedOnly() { - return replicatedOnly; - } - - /** - * @return {@code true} If query should be executed locally. - */ - public boolean isLocal() { - return loc; - } - - /** - * @return Page size. - */ - public int getPageSize() { - return pageSize; - } - - /** - * Lazy query execution flag. - * - * @return Lazy flag. - */ - public boolean getLazy() { - return lazy; - } - - /** - * Flag indicating if this query is collocated. - * - * @return {@code true} If the query is collocated. - */ - public boolean isCollocated() { - return collocated; - } - - /** {@inheritDoc} */ - @Override public byte getProtocolVersion() { - return V3; - } - - /** {@inheritDoc} */ - @Override protected void writeExternalData(ObjectOutput out) throws IOException { - U.writeString(out, cacheName); - U.writeString(out, qryTxt); - out.writeBoolean(distributedJoins); - out.writeBoolean(enforceJoinOrder); - out.writeBoolean(loc); - out.writeInt(pageSize); - out.writeBoolean(lazy); - out.writeBoolean(collocated); - } - - /** {@inheritDoc} */ - @Override protected void readExternalData(byte protoVer, ObjectInput in) throws IOException, ClassNotFoundException { - cacheName = U.readString(in); - qryTxt = U.readString(in); - distributedJoins = in.readBoolean(); - enforceJoinOrder = in.readBoolean(); - loc = in.readBoolean(); - pageSize = in.readInt(); - - if (protoVer > V1) - lazy = in.readBoolean(); - - if (protoVer > V2) - collocated = in.readBoolean(); - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorQueryTaskArg.class, this); - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/query/VisorQueryUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/query/VisorQueryUtils.java deleted file mode 100644 index 39f2251b9864a..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/query/VisorQueryUtils.java +++ /dev/null @@ -1,519 +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.query; - -import java.math.BigDecimal; -import java.net.URL; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.Date; -import java.util.Iterator; -import java.util.List; -import java.util.concurrent.ConcurrentMap; -import javax.cache.Cache; -import org.apache.ignite.IgniteCache; -import org.apache.ignite.IgniteException; -import org.apache.ignite.binary.BinaryObject; -import org.apache.ignite.binary.BinaryObjectException; -import org.apache.ignite.binary.BinaryType; -import org.apache.ignite.cache.CachePeekMode; -import org.apache.ignite.cache.query.FieldsQueryCursor; -import org.apache.ignite.cache.query.QueryCursor; -import org.apache.ignite.cache.query.ScanQuery; -import org.apache.ignite.cache.query.SqlFieldsQuery; -import org.apache.ignite.internal.IgniteEx; -import org.apache.ignite.internal.binary.BinaryObjectEx; -import org.apache.ignite.internal.processors.cache.query.QueryCursorEx; -import org.apache.ignite.internal.processors.query.GridQueryCancel; -import org.apache.ignite.internal.processors.query.GridQueryFieldMetadata; -import org.apache.ignite.internal.processors.timeout.GridTimeoutObjectAdapter; -import org.apache.ignite.internal.util.IgniteUtils; -import org.apache.ignite.internal.util.lang.GridPlainRunnable; -import org.apache.ignite.internal.util.typedef.F; -import org.apache.ignite.internal.util.typedef.internal.S; -import org.apache.ignite.internal.util.typedef.internal.SB; -import org.apache.ignite.internal.util.typedef.internal.U; -import org.apache.ignite.lang.IgniteBiPredicate; - -import static org.apache.ignite.internal.managers.communication.GridIoPolicy.MANAGEMENT_POOL; - -/** - * Contains utility methods for Visor query tasks and jobs. - */ -public class VisorQueryUtils { - /** How long to store future with query in node local map: 5 minutes. */ - public static final Integer RMV_DELAY = 5 * 60 * 1000; - - /** Message for query result expired error. */ - private static final String SQL_QRY_RESULTS_EXPIRED_ERR = "SQL query results are expired."; - - /** Message for scan result expired error. */ - private static final String SCAN_QRY_RESULTS_EXPIRED_ERR = "Scan query results are expired."; - - /** Columns for SCAN queries. */ - public static final List SCAN_COL_NAMES = Arrays.asList( - new VisorQueryField(null, null, "Key Class", ""), new VisorQueryField(null, null, "Key", ""), - new VisorQueryField(null, null, "Value Class", ""), new VisorQueryField(null, null, "Value", "") - ); - - /** - * @param o Source object. - * @return String representation of object class. - */ - private static String typeOf(Object o) { - if (o != null) { - Class clazz = o.getClass(); - - return clazz.isArray() ? IgniteUtils.compact(clazz.getComponentType().getName()) + "[]" - : IgniteUtils.compact(o.getClass().getName()); - } - else - return "n/a"; - } - - /** - * @param o Object. - * @return String representation of value. - */ - private static String valueOf(Object o) { - if (o == null) - return "null"; - - if (o instanceof byte[]) - return "size=" + ((byte[])o).length; - - if (o instanceof Byte[]) - return "size=" + ((Byte[])o).length; - - if (o instanceof Object[]) { - return "size=" + ((Object[])o).length + - ", values=[" + S.joinToString(Arrays.asList((Object[])o), ", ", "...", 120, 0) + "]"; - } - - if (o instanceof BinaryObject) - return binaryToString((BinaryObject)o); - - return o.toString(); - } - - /** - * Fetch rows from SCAN query future. - * - * @param itr Result set iterator. - * @param pageSize Number of rows to fetch. - * @return Fetched rows. - */ - public static List fetchScanQueryRows(Iterator itr, int pageSize) { - List rows = new ArrayList<>(); - - int cnt = 0; - - Iterator> scanItr = (Iterator>)itr; - - while (scanItr.hasNext() && cnt < pageSize) { - Cache.Entry next = scanItr.next(); - - Object k = next.getKey(); - Object v = next.getValue(); - - rows.add(new Object[] {typeOf(k), valueOf(k), typeOf(v), valueOf(v)}); - - cnt++; - } - - return rows; - } - - /** - * Checks is given object is one of known types. - * - * @param obj Object instance to check. - * @return {@code true} if it is one of known types. - */ - private static boolean isKnownType(Object obj) { - return obj instanceof String || - obj instanceof Boolean || - obj instanceof Byte || - obj instanceof Integer || - obj instanceof Long || - obj instanceof Short || - obj instanceof Date || - obj instanceof Double || - obj instanceof Float || - obj instanceof BigDecimal || - obj instanceof URL; - } - - /** - * Convert Binary object to string. - * - * @param obj Binary object. - * @return String representation of Binary object. - */ - public static String binaryToString(BinaryObject obj) { - int hash = obj.hashCode(); - - if (obj instanceof BinaryObjectEx) { - BinaryObjectEx objEx = (BinaryObjectEx)obj; - - BinaryType meta; - - try { - meta = ((BinaryObjectEx)obj).rawType(); - } - catch (BinaryObjectException ignore) { - meta = null; - } - - if (meta != null) { - if (meta.isEnum()) { - try { - return obj.deserialize().toString(); - } - catch (BinaryObjectException ignore) { - // NO-op. - } - } - - SB buf = new SB(meta.typeName()); - - if (meta.fieldNames() != null) { - buf.a(" [hash=").a(hash); - - for (String name : meta.fieldNames()) { - Object val = objEx.field(name); - - buf.a(", ").a(name).a('=').a(val); - } - - buf.a(']'); - - return buf.toString(); - } - } - } - - return S.toString(obj.getClass().getSimpleName(), - "hash", hash, false, - "typeId", obj.type().typeId(), true); - } - - /** - * Convert object that can be passed to client. - * - * @param original Source object. - * @return Converted value. - */ - public static Object convertValue(Object original) { - if (original == null) - return null; - else if (isKnownType(original)) - return original; - else if (original instanceof BinaryObject) - return binaryToString((BinaryObject)original); - else - return original.getClass().isArray() ? "binary" : original.toString(); - } - - /** - * Collects rows from sql query future, first time creates meta and column names arrays. - * - * @param itr Result set iterator. - * @param pageSize Number of rows to fetch. - * @return Fetched rows. - */ - public static List fetchSqlQueryRows(Iterator itr, int pageSize) { - List rows = new ArrayList<>(); - - int cnt = 0; - - Iterator> sqlItr = (Iterator>)itr; - - while (sqlItr.hasNext() && cnt < pageSize) { - List next = sqlItr.next(); - - int sz = next.size(); - - Object[] row = new Object[sz]; - - for (int i = 0; i < sz; i++) - row[i] = convertValue(next.get(i)); - - rows.add(row); - - cnt++; - } - - return rows; - } - - /** - * Get holder for query or throw exception if not found. - * - * @param ignite IgniteEx instance. - * @param qryId Query ID to get holder. - * @return Query holder for specified query ID. - * @throws IgniteException When holder is not found. - */ - public static VisorQueryHolder getQueryHolder(final IgniteEx ignite, final String qryId) throws IgniteException { - ConcurrentMap storage = ignite.cluster().nodeLocalMap(); - - VisorQueryHolder holder = storage.get(qryId); - - if (holder == null) - throw new IgniteException(VisorQueryHolder.isSqlQuery(qryId) - ? SQL_QRY_RESULTS_EXPIRED_ERR - : SCAN_QRY_RESULTS_EXPIRED_ERR); - - return holder; - } - - /** - * Remove query holder from local storage for query with specified ID and cancel query if it is in progress. - * - * @param ignite IgniteEx instance. - * @param qryId Query ID to get holder. - */ - public static void removeQueryHolder(final IgniteEx ignite, final String qryId) { - ConcurrentMap storage = ignite.cluster().nodeLocalMap(); - VisorQueryHolder holder = storage.remove(qryId); - - if (holder != null) - holder.close(); - } - - /** - * Fetch rows from query cursor. - * - * @param itr Result set iterator. - * @param qryId Query ID. - * @param pageSize Page size. - */ - public static List fetchQueryRows(Iterator itr, String qryId, int pageSize) { - return itr.hasNext() - ? (VisorQueryHolder.isSqlQuery(qryId) - ? fetchSqlQueryRows(itr, pageSize) - : fetchScanQueryRows(itr, pageSize)) - : Collections.emptyList(); - } - - /** - * Schedule start of SQL query execution. - * - * @param ignite IgniteEx instance. - * @param holder Query holder object. - * @param arg Query task argument with query properties. - * @param cancel Object to cancel query. - */ - public static void scheduleQueryStart( - final IgniteEx ignite, - final VisorQueryHolder holder, - final VisorQueryTaskArg arg, - final GridQueryCancel cancel - ) { - ignite.context().closure().runLocalSafe((GridPlainRunnable)() -> { - try { - SqlFieldsQuery qry = new SqlFieldsQuery(arg.getQueryText()); - - qry.setPageSize(arg.getPageSize()); - qry.setLocal(arg.isLocal()); - qry.setDistributedJoins(arg.isDistributedJoins()); - qry.setCollocated(arg.isCollocated()); - qry.setEnforceJoinOrder(arg.isEnforceJoinOrder()); - qry.setReplicatedOnly(arg.isReplicatedOnly()); - qry.setLazy(arg.getLazy()); - - String cacheName = arg.getCacheName(); - - if (!F.isEmpty(cacheName)) - qry.setSchema(cacheName); - - long start = U.currentTimeMillis(); - - List>> qryCursors = ignite - .context() - .query() - .querySqlFields(null, qry, null, true, false, cancel); - - // In case of multiple statements leave opened only last cursor. - for (int i = 0; i < qryCursors.size() - 1; i++) - U.closeQuiet(qryCursors.get(i)); - - // In case of multiple statements return last cursor as result. - FieldsQueryCursor> cur = F.last(qryCursors); - - try { - // Ensure holder was not removed from node local storage from separate thread if user cancel query. - VisorQueryHolder actualHolder = getQueryHolder(ignite, holder.getQueryID()); - - List meta = ((QueryCursorEx)cur).fieldsMeta(); - - if (meta == null) - actualHolder.setError(new SQLException("Fail to execute query. No metadata available.")); - else { - List cols = new ArrayList<>(meta.size()); - - for (GridQueryFieldMetadata col : meta) { - cols.add(new VisorQueryField( - col.schemaName(), - col.typeName(), - col.fieldName(), - col.fieldTypeName()) - ); - } - - actualHolder.complete(cur, U.currentTimeMillis() - start, cols); - - scheduleQueryHolderRemoval(ignite, actualHolder.getQueryID()); - } - } - catch (Throwable e) { - U.closeQuiet(cur); - - throw e; - } - } - catch (Throwable e) { - holder.setError(e); - } - }, MANAGEMENT_POOL); - } - - /** - * Schedule start of SCAN query execution. - * - * @param ignite IgniteEx instance. - * @param holder Query holder object. - * @param arg Query task argument with query properties. - */ - public static void scheduleScanStart( - final IgniteEx ignite, - final VisorQueryHolder holder, - final VisorScanQueryTaskArg arg - ) { - ignite.context().closure().runLocalSafe((GridPlainRunnable)() -> { - try { - IgniteCache c = ignite.cache(arg.getCacheName()); - String filterText = arg.getFilter(); - IgniteBiPredicate filter = null; - - if (!F.isEmpty(filterText)) - filter = new VisorQueryScanRegexFilter(arg.isCaseSensitive(), arg.isRegEx(), filterText); - - QueryCursor> cur; - - long start = U.currentTimeMillis(); - - if (arg.isNear()) - cur = new VisorNearCacheCursor<>(c.localEntries(CachePeekMode.NEAR).iterator()); - else { - ScanQuery qry = new ScanQuery<>(filter); - qry.setPageSize(arg.getPageSize()); - qry.setLocal(arg.isLocal()); - - cur = c.withKeepBinary().query(qry); - } - - try { - // Ensure holder was not removed from node local storage from separate thread if user cancel query. - VisorQueryHolder actualHolder = getQueryHolder(ignite, holder.getQueryID()); - - actualHolder.complete(cur, U.currentTimeMillis() - start, SCAN_COL_NAMES); - - scheduleQueryHolderRemoval(ignite, actualHolder.getQueryID()); - } - catch (Throwable e) { - U.closeQuiet(cur); - - throw e; - } - } - catch (Throwable e) { - holder.setError(e); - } - }, MANAGEMENT_POOL); - } - - /** - * Wrapper for cache iterator to behave like {@link QueryCursor}. - */ - private static class VisorNearCacheCursor implements QueryCursor { - /** Wrapped iterator. */ - private final Iterator it; - - /** - * Wrapping constructor. - * - * @param it Near cache iterator to wrap. - */ - private VisorNearCacheCursor(Iterator it) { - this.it = it; - } - - /** {@inheritDoc} */ - @Override public List getAll() { - List all = new ArrayList<>(); - - while (it.hasNext()) - all.add(it.next()); - - return all; - } - - /** {@inheritDoc} */ - @Override public void close() { - // Nothing to close. - } - - /** {@inheritDoc} */ - @Override public Iterator iterator() { - return it; - } - } - - /** - * Schedule clearing of query context by timeout. - * - * @param qryId Unique query result id. - * @param ignite IgniteEx instance. - */ - public static void scheduleQueryHolderRemoval(final IgniteEx ignite, final String qryId) { - ignite.context().timeout().addTimeoutObject(new GridTimeoutObjectAdapter(RMV_DELAY) { - @Override public void onTimeout() { - ConcurrentMap storage = ignite.cluster().nodeLocalMap(); - - VisorQueryHolder holder = storage.get(qryId); - - if (holder != null) { - if (holder.isAccessed()) { - holder.setAccessed(false); - - // Holder was accessed, we need to keep it for one more period. - scheduleQueryHolderRemoval(ignite, qryId); - } - else { - // Remove stored cursor otherwise. - removeQueryHolder(ignite, qryId); - } - } - } - }); - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/query/VisorRunningQueriesCollectorTask.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/query/VisorRunningQueriesCollectorTask.java deleted file mode 100644 index 535799fb94a54..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/query/VisorRunningQueriesCollectorTask.java +++ /dev/null @@ -1,101 +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.query; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.UUID; -import org.apache.ignite.IgniteException; -import org.apache.ignite.compute.ComputeJobResult; -import org.apache.ignite.internal.processors.query.GridRunningQueryInfo; -import org.apache.ignite.internal.processors.task.GridInternal; -import org.apache.ignite.internal.util.typedef.internal.U; -import org.apache.ignite.internal.visor.VisorJob; -import org.apache.ignite.internal.visor.VisorMultiNodeTask; -import org.jetbrains.annotations.Nullable; - -/** - * Task to collect currently running queries. - */ -@GridInternal -public class VisorRunningQueriesCollectorTask extends - VisorMultiNodeTask>, Collection> { - /** */ - private static final long serialVersionUID = 0L; - - /** {@inheritDoc} */ - @Override protected VisorCollectRunningQueriesJob job(VisorRunningQueriesCollectorTaskArg arg) { - return new VisorCollectRunningQueriesJob(arg, debug); - } - - /** {@inheritDoc} */ - @Nullable @Override protected Map> reduce0(List results) throws IgniteException { - Map> map = new HashMap<>(); - - for (ComputeJobResult res : results) - if (res.getException() == null) { - Collection queries = res.getData(); - - map.put(res.getNode().id(), queries); - } - - return map; - } - - /** - * Job to collect currently running queries from node. - */ - private static class VisorCollectRunningQueriesJob - extends VisorJob> { - /** */ - private static final long serialVersionUID = 0L; - - /** - * Create job with specified argument. - * - * @param arg Job argument. - * @param debug Flag indicating whether debug information should be printed into node log. - */ - protected VisorCollectRunningQueriesJob(@Nullable VisorRunningQueriesCollectorTaskArg arg, boolean debug) { - super(arg, debug); - } - - /** {@inheritDoc} */ - @Override protected Collection run(@Nullable VisorRunningQueriesCollectorTaskArg arg) - throws IgniteException { - assert arg != null; - - Collection queries = ignite.context().query() - .runningQueries(arg.getDuration()); - - Collection res = new ArrayList<>(queries.size()); - - long curTime = U.currentTimeMillis(); - - for (GridRunningQueryInfo qry : queries) - res.add(new VisorRunningQuery(qry.id(), qry.query(), qry.queryType(), qry.schemaName(), - qry.startTime(), curTime - qry.startTime(), - qry.cancelable(), qry.local())); - - return res; - } - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/query/VisorRunningQueriesCollectorTaskArg.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/query/VisorRunningQueriesCollectorTaskArg.java deleted file mode 100644 index 2de61c5cc008e..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/query/VisorRunningQueriesCollectorTaskArg.java +++ /dev/null @@ -1,71 +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.query; - -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.visor.VisorDataTransferObject; - -/** - * Arguments for task {@link VisorRunningQueriesCollectorTask} - */ -public class VisorRunningQueriesCollectorTaskArg extends VisorDataTransferObject { - /** */ - private static final long serialVersionUID = 0L; - - /** Duration to check. */ - private long duration; - - /** - * Default constructor. - */ - public VisorRunningQueriesCollectorTaskArg() { - // No-op. - } - - /** - * @param duration Duration to check. - */ - public VisorRunningQueriesCollectorTaskArg(long duration) { - this.duration = duration; - } - - /** - * @return Duration to check. - */ - public long getDuration() { - return duration; - } - - /** {@inheritDoc} */ - @Override protected void writeExternalData(ObjectOutput out) throws IOException { - out.writeLong(duration); - } - - /** {@inheritDoc} */ - @Override protected void readExternalData(byte protoVer, ObjectInput in) throws IOException, ClassNotFoundException { - duration = in.readLong(); - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorRunningQueriesCollectorTaskArg.class, this); - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/query/VisorRunningQuery.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/query/VisorRunningQuery.java deleted file mode 100644 index 47f4436fbefaf..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/query/VisorRunningQuery.java +++ /dev/null @@ -1,175 +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.query; - -import java.io.IOException; -import java.io.ObjectInput; -import java.io.ObjectOutput; -import org.apache.ignite.internal.processors.cache.query.GridCacheQueryType; -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; - -/** - * Descriptor of running query. - */ -public class VisorRunningQuery extends VisorDataTransferObject { - /** */ - private static final long serialVersionUID = 0L; - - /** */ - private long id; - - /** Query text. */ - private String qry; - - /** Query type. */ - private GridCacheQueryType qryType; - - /** Schema name. */ - private String schemaName; - - /** */ - private long startTime; - - /** */ - private long duration; - - /** */ - private boolean cancellable; - - /** */ - private boolean loc; - - /** - * Default constructor. - */ - public VisorRunningQuery() { - // No-op. - } - - /** - * Construct data transfer object for running query information. - * - * @param id Query ID. - * @param qry Query text. - * @param qryType Query type. - * @param schemaName Query schema name. - * @param startTime Query start time. - * @param duration Query current duration. - * @param cancellable {@code true} if query can be canceled. - * @param loc {@code true} if query is local. - */ - public VisorRunningQuery(long id, String qry, GridCacheQueryType qryType, String schemaName, - long startTime, long duration, - boolean cancellable, boolean loc) { - this.id = id; - this.qry = qry; - this.qryType = qryType; - this.schemaName = schemaName; - this.startTime = startTime; - this.duration = duration; - this.cancellable = cancellable; - this.loc = loc; - } - - /** - * @return Query ID. - */ - public long getId() { - return id; - } - - /** - * @return Query txt. - */ - public String getQuery() { - return qry; - } - - /** - * @return Query type. - */ - public GridCacheQueryType getQueryType() { - return qryType; - } - - /** - * @return Schema name. - */ - public String getSchemaName() { - return schemaName; - } - - /** - * @return Query start time. - */ - public long getStartTime() { - return startTime; - } - - /** - * @return Query duration. - */ - public long getDuration() { - return duration; - } - - /** - * @return {@code true} if query can be cancelled. - */ - public boolean isCancelable() { - return cancellable; - } - - /** - * @return {@code true} if query is local. - */ - public boolean isLocal() { - return loc; - } - - /** {@inheritDoc} */ - @Override protected void writeExternalData(ObjectOutput out) throws IOException { - out.writeLong(id); - U.writeString(out, qry); - U.writeEnum(out, qryType); - U.writeString(out, schemaName); - out.writeLong(startTime); - out.writeLong(duration); - out.writeBoolean(cancellable); - out.writeBoolean(loc); - } - - /** {@inheritDoc} */ - @Override protected void readExternalData(byte protoVer, ObjectInput in) throws IOException, ClassNotFoundException { - id = in.readLong(); - qry = U.readString(in); - qryType = GridCacheQueryType.fromOrdinal(in.readByte()); - schemaName = U.readString(in); - startTime = in.readLong(); - duration = in.readLong(); - cancellable = in.readBoolean(); - loc = in.readBoolean(); - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorRunningQuery.class, this); - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/query/VisorScanQueryTask.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/query/VisorScanQueryTask.java deleted file mode 100644 index 7c0fac9710f86..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/query/VisorScanQueryTask.java +++ /dev/null @@ -1,83 +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.query; - -import java.util.UUID; -import org.apache.ignite.internal.processors.task.GridInternal; -import org.apache.ignite.internal.util.typedef.internal.S; -import org.apache.ignite.internal.visor.VisorEither; -import org.apache.ignite.internal.visor.VisorJob; -import org.apache.ignite.internal.visor.VisorOneNodeTask; -import org.apache.ignite.internal.visor.util.VisorExceptionWrapper; - -import static org.apache.ignite.internal.visor.query.VisorQueryUtils.scheduleScanStart; - -/** - * Task for execute SCAN query and get first page of results. - */ -@GridInternal -public class VisorScanQueryTask extends VisorOneNodeTask> { - /** */ - private static final long serialVersionUID = 0L; - - /** {@inheritDoc} */ - @Override protected VisorScanQueryJob job(VisorScanQueryTaskArg arg) { - return new VisorScanQueryJob(arg, debug); - } - - /** - * Job for execute SCAN query and get first page of results. - */ - private static class VisorScanQueryJob extends VisorJob> { - /** */ - private static final long serialVersionUID = 0L; - - /** - * Create job with specified argument. - * - * @param arg Job argument. - * @param debug Debug flag. - */ - private VisorScanQueryJob(VisorScanQueryTaskArg arg, boolean debug) { - super(arg, debug); - } - - /** {@inheritDoc} */ - @Override protected VisorEither run(final VisorScanQueryTaskArg arg) { - try { - UUID nid = ignite.localNode().id(); - - VisorQueryHolder holder = new VisorQueryHolder(false, null, null); - - ignite.cluster().nodeLocalMap().put(holder.getQueryID(), holder); - - scheduleScanStart(ignite, holder, arg); - - return new VisorEither<>(new VisorQueryResult(nid, holder.getQueryID(), null, null, false, 0)); - } - catch (Throwable e) { - return new VisorEither<>(new VisorExceptionWrapper(e)); - } - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorScanQueryJob.class, this); - } - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/query/VisorScanQueryTaskArg.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/query/VisorScanQueryTaskArg.java deleted file mode 100644 index 314a7c4681ab3..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/query/VisorScanQueryTaskArg.java +++ /dev/null @@ -1,157 +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.query; - -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; - -/** - * Arguments for {@link VisorScanQueryTask}. - */ -public class VisorScanQueryTaskArg extends VisorDataTransferObject { - /** */ - private static final long serialVersionUID = 0L; - - /** Cache name for query. */ - private String cacheName; - - /** Filter text. */ - private String filter; - - /** Filter is regular expression */ - private boolean regEx; - - /** Case sensitive filtration */ - private boolean caseSensitive; - - /** Scan of near cache */ - private boolean near; - - /** Flag whether to execute query locally. */ - private boolean loc; - - /** Result batch size. */ - private int pageSize; - - /** - * Default constructor. - */ - public VisorScanQueryTaskArg() { - // No-op. - } - - /** - * @param cacheName Cache name for query. - * @param filter Filter text. - * @param regEx Filter is regular expression. - * @param caseSensitive Case sensitive filtration. - * @param near Scan near cache. - * @param loc Flag whether to execute query locally. - * @param pageSize Result batch size. - */ - public VisorScanQueryTaskArg(String cacheName, String filter, boolean regEx, boolean caseSensitive, boolean near, - boolean loc, int pageSize) { - this.cacheName = cacheName; - this.filter = filter; - this.regEx = regEx; - this.caseSensitive = caseSensitive; - this.near = near; - this.loc = loc; - this.pageSize = pageSize; - } - - /** - * @return Cache name. - */ - public String getCacheName() { - return cacheName; - } - - /** - * @return Filter is regular expression. - */ - public boolean isRegEx() { - return regEx; - } - - /** - * @return Filter. - */ - public String getFilter() { - return filter; - } - - /** - * @return Case sensitive filtration. - */ - public boolean isCaseSensitive() { - return caseSensitive; - } - - /** - * @return Scan of near cache. - */ - public boolean isNear() { - return near; - } - - /** - * @return {@code true} if query should be executed locally. - */ - public boolean isLocal() { - return loc; - } - - /** - * @return Page size. - */ - public int getPageSize() { - return pageSize; - } - - /** {@inheritDoc} */ - @Override protected void writeExternalData(ObjectOutput out) throws IOException { - U.writeString(out, cacheName); - U.writeString(out, filter); - out.writeBoolean(regEx); - out.writeBoolean(caseSensitive); - out.writeBoolean(near); - out.writeBoolean(loc); - out.writeInt(pageSize); - } - - /** {@inheritDoc} */ - @Override protected void readExternalData(byte protoVer, ObjectInput in) throws IOException, ClassNotFoundException { - cacheName = U.readString(in); - filter = U.readString(in); - regEx = in.readBoolean(); - caseSensitive = in.readBoolean(); - near = in.readBoolean(); - loc = in.readBoolean(); - pageSize = in.readInt(); - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorScanQueryTaskArg.class, this); - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/service/VisorServiceDescriptor.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/service/VisorServiceDescriptor.java deleted file mode 100644 index 4cfd1503fcb7d..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/service/VisorServiceDescriptor.java +++ /dev/null @@ -1,166 +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.service; - -import java.io.IOException; -import java.io.ObjectInput; -import java.io.ObjectOutput; -import java.util.Map; -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.VisorDataTransferObject; -import org.apache.ignite.internal.visor.util.VisorTaskUtils; -import org.apache.ignite.services.ServiceDescriptor; - -/** - * Data transfer object for {@link ServiceDescriptor} object. - */ -public class VisorServiceDescriptor extends VisorDataTransferObject { - /** */ - private static final long serialVersionUID = 0L; - - /** Service name. */ - private String name; - - /** Service class. */ - private String srvcCls; - - /** Maximum allowed total number of deployed services in the grid, {@code 0} for unlimited. */ - private int totalCnt; - - /** Maximum allowed number of deployed services on each node. */ - private int maxPerNodeCnt; - - /** Cache name used for key-to-node affinity calculation. */ - private String cacheName; - - /** ID of grid node that initiated the service deployment. */ - private UUID originNodeId; - - /** - * Service deployment topology snapshot. - * Number of service instances deployed on a node mapped to node ID. - */ - private Map topSnapshot; - - /** - * Default constructor. - */ - public VisorServiceDescriptor() { - // No-op. - } - - /** - * Create task result with given parameters - * - * @param srvc Service descriptor to transfer. - */ - public VisorServiceDescriptor(ServiceDescriptor srvc) { - name = srvc.name(); - - try { - srvcCls = VisorTaskUtils.compactClass(srvc.serviceClass()); - } - catch (Throwable e) { - srvcCls = e.getClass().getName() + ": " + e.getMessage(); - } - - totalCnt = srvc.totalCount(); - maxPerNodeCnt = srvc.maxPerNodeCount(); - cacheName = srvc.cacheName(); - originNodeId = srvc.originNodeId(); - topSnapshot = srvc.topologySnapshot(); - } - - /** - * @return Service name. - */ - public String getName() { - return name; - } - - /** - * @return Service class. - */ - public String getServiceClass() { - return srvcCls; - } - - /** - * @return Maximum allowed total number of deployed services in the grid, 0 for unlimited. - */ - public int getTotalCnt() { - return totalCnt; - } - - /** - * @return Maximum allowed number of deployed services on each node. - */ - public int getMaxPerNodeCnt() { - return maxPerNodeCnt; - } - - /** - * @return Cache name used for key-to-node affinity calculation. - */ - public String getCacheName() { - return cacheName; - } - - /** - * @return ID of grid node that initiated the service deployment. - */ - public UUID getOriginNodeId() { - return originNodeId; - } - - /** - * @return Service deployment topology snapshot. Number of service instances deployed on a node mapped to node ID. - */ - public Map getTopologySnapshot() { - return topSnapshot; - } - - /** {@inheritDoc} */ - @Override protected void writeExternalData(ObjectOutput out) throws IOException { - U.writeString(out, name); - U.writeString(out, srvcCls); - out.writeInt(totalCnt); - out.writeInt(maxPerNodeCnt); - U.writeString(out, cacheName); - U.writeUuid(out, originNodeId); - U.writeMap(out, topSnapshot); - } - - /** {@inheritDoc} */ - @Override protected void readExternalData(byte protoVer, ObjectInput in) throws IOException, ClassNotFoundException { - name = U.readString(in); - srvcCls = U.readString(in); - totalCnt = in.readInt(); - maxPerNodeCnt = in.readInt(); - cacheName = U.readString(in); - originNodeId = U.readUuid(in); - topSnapshot = U.readMap(in); - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorServiceDescriptor.class, this); - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/service/VisorServiceTask.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/service/VisorServiceTask.java deleted file mode 100644 index e2a1fb7024720..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/service/VisorServiceTask.java +++ /dev/null @@ -1,77 +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.service; - -import java.util.ArrayList; -import java.util.Collection; -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.VisorOneNodeTask; -import org.apache.ignite.services.ServiceDescriptor; - -/** - * Task for collect topology service configuration. - */ -@GridInternal -public class VisorServiceTask extends VisorOneNodeTask> { - /** */ - private static final long serialVersionUID = 0L; - - /** {@inheritDoc} */ - @Override protected VisorServiceJob job(Void arg) { - return new VisorServiceJob(arg, debug); - } - - /** - * Job for collect topology service configuration. - */ - private static class VisorServiceJob extends VisorJob> { - /** */ - private static final long serialVersionUID = 0L; - - /** - * Create job with specified argument. - * - * @param arg Job argument. - * @param debug Debug flag. - */ - protected VisorServiceJob(Void arg, boolean debug) { - super(arg, debug); - } - - /** {@inheritDoc} */ - @Override protected Collection run(final Void arg) { - Collection res = new ArrayList<>(); - - if (ignite.cluster().active()) { - Collection services = ignite.services().serviceDescriptors(); - - for (ServiceDescriptor srvc : services) - res.add(new VisorServiceDescriptor(srvc)); - } - - return res; - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorServiceJob.class, this); - } - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/util/VisorEventMapper.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/util/VisorEventMapper.java deleted file mode 100644 index 0a2c2b4070465..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/util/VisorEventMapper.java +++ /dev/null @@ -1,147 +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.util; - -import java.util.UUID; -import org.apache.ignite.cluster.ClusterNode; -import org.apache.ignite.events.DeploymentEvent; -import org.apache.ignite.events.DiscoveryEvent; -import org.apache.ignite.events.Event; -import org.apache.ignite.events.JobEvent; -import org.apache.ignite.events.TaskEvent; -import org.apache.ignite.internal.util.typedef.F; -import org.apache.ignite.internal.visor.event.VisorGridDeploymentEvent; -import org.apache.ignite.internal.visor.event.VisorGridDiscoveryEvent; -import org.apache.ignite.internal.visor.event.VisorGridEvent; -import org.apache.ignite.internal.visor.event.VisorGridJobEvent; -import org.apache.ignite.internal.visor.event.VisorGridTaskEvent; -import org.apache.ignite.lang.IgniteClosure; -import org.apache.ignite.lang.IgniteUuid; - -/** - * Mapper from grid event to Visor data transfer object. - */ -public class VisorEventMapper implements IgniteClosure { - /** */ - private static final long serialVersionUID = 0L; - - /** - * Map grid event to Visor data transfer object. - * - * @param evt Grid event. - * @param type Event's type. - * @param id Event id. - * @param name Event name. - * @param nid Event node ID. - * @param ts Event timestamp. - * @param msg Event message. - * @param shortDisplay Shortened version of {@code toString()} result. - * @return Visor data transfer object for event. - */ - protected VisorGridEvent map(Event evt, int type, IgniteUuid id, String name, UUID nid, long ts, String msg, - String shortDisplay) { - if (evt instanceof TaskEvent) - return taskEvent((TaskEvent)evt, type, id, name, nid, ts, msg, shortDisplay); - - if (evt instanceof JobEvent) - return jobEvent((JobEvent)evt, type, id, name, nid, ts, msg, shortDisplay); - - if (evt instanceof DeploymentEvent) - return deploymentEvent((DeploymentEvent)evt, type, id, name, nid, ts, msg, shortDisplay); - - if (evt instanceof DiscoveryEvent) - return discoveryEvent((DiscoveryEvent)evt, type, id, name, nid, ts, msg, shortDisplay); - - return null; - } - - /** - * @param te Task event. - * @param type Event's type. - * @param id Event id. - * @param name Event name. - * @param nid Event node ID. - * @param ts Event timestamp. - * @param msg Event message. - * @param shortDisplay Shortened version of {@code toString()} result. - * @return Visor data transfer object for event. - */ - protected VisorGridEvent taskEvent(TaskEvent te, int type, IgniteUuid id, String name, UUID nid, long ts, - String msg, String shortDisplay) { - return new VisorGridTaskEvent(type, id, name, nid, ts, msg, shortDisplay, - te.taskName(), te.taskClassName(), te.taskSessionId(), te.internal()); - } - - /** - * @param je Job event. - * @param type Event's type. - * @param id Event id. - * @param name Event name. - * @param nid Event node ID. - * @param ts Event timestamp. - * @param msg Event message. - * @param shortDisplay Shortened version of {@code toString()} result. - * @return Visor data transfer object for event. - */ - protected VisorGridEvent jobEvent(JobEvent je, int type, IgniteUuid id, String name, UUID nid, long ts, - String msg, String shortDisplay) { - return new VisorGridJobEvent(type, id, name, nid, ts, msg, shortDisplay, je.taskName(), je.taskClassName(), - je.taskSessionId(), je.jobId()); - } - - /** - * @param de Deployment event. - * @param type Event's type. - * @param id Event id. - * @param name Event name. - * @param nid Event node ID. - * @param ts Event timestamp. - * @param msg Event message. - * @param shortDisplay Shortened version of {@code toString()} result. - * @return Visor data transfer object for event. - */ - protected VisorGridEvent deploymentEvent(DeploymentEvent de, int type, IgniteUuid id, String name, UUID nid, - long ts, String msg, String shortDisplay) { - return new VisorGridDeploymentEvent(type, id, name, nid, ts, msg, shortDisplay, de.alias()); - } - - /** - * @param de Discovery event. - * @param type Event's type. - * @param id Event id. - * @param name Event name. - * @param nid Event node ID. - * @param ts Event timestamp. - * @param msg Event message. - * @param shortDisplay Shortened version of {@code toString()} result. - * @return Visor data transfer object for event. - */ - protected VisorGridEvent discoveryEvent(DiscoveryEvent de, int type, IgniteUuid id, String name, UUID nid, - long ts, String msg, String shortDisplay) { - ClusterNode node = de.eventNode(); - - return new VisorGridDiscoveryEvent(type, id, name, nid, ts, msg, shortDisplay, node.id(), - F.first(node.addresses()), de.topologyVersion()); - } - - /** {@inheritDoc} */ - @Override public VisorGridEvent apply(Event evt) { - return map(evt, evt.type(), evt.id(), evt.name(), evt.node().id(), evt.timestamp(), evt.message(), - evt.shortDisplay()); - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/util/VisorMimeTypes.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/util/VisorMimeTypes.java deleted file mode 100644 index 449395deae7b5..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/util/VisorMimeTypes.java +++ /dev/null @@ -1,1019 +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.util; - -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.util.Map; -import org.apache.ignite.internal.util.typedef.internal.U; -import org.jetbrains.annotations.Nullable; - -/** - * Helper class to get MIME type. - */ -public class VisorMimeTypes { - /** Bytes to read from file for mimetype detection. */ - private static final int PREVIEW_SIZE = 11; - - /** Common MIME types. */ - private static final Map mimeTypes = U.newHashMap(810); - - static { - mimeTypes.put("mseed", "application/vnd.fdsn.mseed"); - mimeTypes.put("vsf", "application/vnd.vsf"); - mimeTypes.put("cmdf", "chemical/x-cmdf"); - mimeTypes.put("mxs", "application/vnd.triscape.mxs"); - mimeTypes.put("m4v", "video/x-m4v"); - mimeTypes.put("oga", "audio/ogg"); - mimeTypes.put("ogg", "audio/ogg"); - mimeTypes.put("spx", "audio/ogg"); - mimeTypes.put("shf", "application/shf+xml"); - mimeTypes.put("jisp", "application/vnd.jisp"); - mimeTypes.put("sgl", "application/vnd.stardivision.writer-global"); - mimeTypes.put("gxt", "application/vnd.geonext"); - mimeTypes.put("mp4s", "application/mp4"); - mimeTypes.put("smi", "application/smil+xml"); - mimeTypes.put("smil", "application/smil+xml"); - mimeTypes.put("xop", "application/xop+xml"); - mimeTypes.put("spl", "application/x-futuresplash"); - mimeTypes.put("spq", "application/scvp-vp-request"); - mimeTypes.put("bh2", "application/vnd.fujitsu.oasysprs"); - mimeTypes.put("xpm", "image/x-xpixmap"); - mimeTypes.put("gdl", "model/vnd.gdl"); - mimeTypes.put("dotx", "application/vnd.openxmlformats-officedocument.wordprocessingml.template"); - mimeTypes.put("ser", "application/java-serialized-object"); - mimeTypes.put("ghf", "application/vnd.groove-help"); - mimeTypes.put("mc1", "application/vnd.medcalcdata"); - mimeTypes.put("cdy", "application/vnd.cinderella"); - mimeTypes.put("nns", "application/vnd.noblenet-sealer"); - mimeTypes.put("msty", "application/vnd.muvee.style"); - mimeTypes.put("aas", "application/x-authorware-seg"); - mimeTypes.put("p", "text/x-pascal"); - mimeTypes.put("pas", "text/x-pascal"); - mimeTypes.put("rdz", "application/vnd.data-vision.rdz"); - mimeTypes.put("js", "text/javascript"); - mimeTypes.put("fzs", "application/vnd.fuzzysheet"); - mimeTypes.put("csml", "chemical/x-csml"); - mimeTypes.put("psf", "application/x-font-linux-psf"); - mimeTypes.put("afp", "application/vnd.ibm.modcap"); - mimeTypes.put("listafp", "application/vnd.ibm.modcap"); - mimeTypes.put("list3820", "application/vnd.ibm.modcap"); - mimeTypes.put("qt", "video/quicktime"); - mimeTypes.put("mov", "video/quicktime"); - mimeTypes.put("fly", "text/vnd.fly"); - mimeTypes.put("rlc", "image/vnd.fujixerox.edmics-rlc"); - mimeTypes.put("sxi", "application/vnd.sun.xml.impress"); - mimeTypes.put("vor", "application/vnd.stardivision.writer"); - mimeTypes.put("gac", "application/vnd.groove-account"); - mimeTypes.put("sldm", "application/vnd.ms-powerpoint.slide.macroenabled.12"); - mimeTypes.put("pgn", "application/x-chess-pgn"); - mimeTypes.put("zaz", "application/vnd.zzazz.deck+xml"); - mimeTypes.put("ccxml", "application/ccxml+xml"); - mimeTypes.put("csh", "application/x-csh"); - mimeTypes.put("fvt", "video/vnd.fvt"); - mimeTypes.put("grv", "application/vnd.groove-injector"); - mimeTypes.put("scurl", "text/vnd.curl.scurl"); - mimeTypes.put("oa3", "application/vnd.fujitsu.oasys3"); - mimeTypes.put("oa2", "application/vnd.fujitsu.oasys2"); - mimeTypes.put("rgb", "image/x-rgb"); - mimeTypes.put("pfr", "application/font-tdpfr"); - mimeTypes.put("pbd", "application/vnd.powerbuilder6"); - mimeTypes.put("psd", "image/vnd.adobe.photoshop"); - mimeTypes.put("fh", "image/x-freehand"); - mimeTypes.put("fhc", "image/x-freehand"); - mimeTypes.put("fh4", "image/x-freehand"); - mimeTypes.put("fh5", "image/x-freehand"); - mimeTypes.put("fh7", "image/x-freehand"); - mimeTypes.put("doc", "application/msword"); - mimeTypes.put("dot", "application/msword"); - mimeTypes.put("docx", "application/vnd.openxmlformats-officedocument.wordprocessingml.document"); - mimeTypes.put("plc", "application/vnd.mobius.plc"); - mimeTypes.put("rnc", "application/relax-ng-compact-syntax"); - mimeTypes.put("rpss", "application/vnd.nokia.radio-presets"); - mimeTypes.put("nlu", "application/vnd.neurolanguage.nlu"); - mimeTypes.put("pcl", "application/vnd.hp-pcl"); - mimeTypes.put("uu", "text/x-uuencode"); - mimeTypes.put("ami", "application/vnd.amiga.ami"); - mimeTypes.put("viv", "video/vnd.vivo"); - mimeTypes.put("mp4a", "audio/mp4"); - mimeTypes.put("vis", "application/vnd.visionary"); - mimeTypes.put("asc", "application/pgp-signature"); - mimeTypes.put("sig", "application/pgp-signature"); - mimeTypes.put("karbon", "application/vnd.kde.karbon"); - mimeTypes.put("htke", "application/vnd.kenameaapp"); - mimeTypes.put("nnd", "application/vnd.noblenet-directory"); - mimeTypes.put("xlsm", "application/vnd.ms-excel.sheet.macroenabled.12"); - mimeTypes.put("ez2", "application/vnd.ezpix-album"); - mimeTypes.put("otm", "application/vnd.oasis.opendocument.text-master"); - mimeTypes.put("f", "text/x-fortran"); - mimeTypes.put("for", "text/x-fortran"); - mimeTypes.put("f77", "text/x-fortran"); - mimeTypes.put("f90", "text/x-fortran"); - mimeTypes.put("apr", "application/vnd.lotus-approach"); - mimeTypes.put("mid", "audio/midi"); - mimeTypes.put("midi", "audio/midi"); - mimeTypes.put("kar", "audio/midi"); - mimeTypes.put("rmi", "audio/midi"); - mimeTypes.put("tmo", "application/vnd.tmobile-livetv"); - mimeTypes.put("pya", "audio/vnd.ms-playready.media.pya"); - mimeTypes.put("cgm", "image/cgm"); - mimeTypes.put("uri", "text/uri-list"); - mimeTypes.put("uris", "text/uri-list"); - mimeTypes.put("urls", "text/uri-list"); - mimeTypes.put("ipk", "application/vnd.shana.informed.package"); - mimeTypes.put("clkk", "application/vnd.crick.clicker.keyboard"); - mimeTypes.put("mbox", "application/mbox"); - mimeTypes.put("unityweb", "application/vnd.unity"); - mimeTypes.put("joda", "application/vnd.joost.joda-archive"); - mimeTypes.put("kwd", "application/vnd.kde.kword"); - mimeTypes.put("kwt", "application/vnd.kde.kword"); - mimeTypes.put("mpy", "application/vnd.ibm.minipay"); - mimeTypes.put("mpeg", "video/mpeg"); - mimeTypes.put("mpg", "video/mpeg"); - mimeTypes.put("mpe", "video/mpeg"); - mimeTypes.put("m1v", "video/mpeg"); - mimeTypes.put("m2v", "video/mpeg"); - mimeTypes.put("asf", "video/x-ms-asf"); - mimeTypes.put("asx", "video/x-ms-asf"); - mimeTypes.put("jad", "text/vnd.sun.j2me.app-descriptor"); - mimeTypes.put("rm", "application/vnd.rn-realmedia"); - mimeTypes.put("xer", "application/patch-ops-error+xml"); - mimeTypes.put("xml", "application/xml"); - mimeTypes.put("xsl", "application/xml"); - mimeTypes.put("icc", "application/vnd.iccprofile"); - mimeTypes.put("icm", "application/vnd.iccprofile"); - mimeTypes.put("mmr", "image/vnd.fujixerox.edmics-mmr"); - mimeTypes.put("hvd", "application/vnd.yamaha.hv-dic"); - mimeTypes.put("mbk", "application/vnd.mobius.mbk"); - mimeTypes.put("123", "application/vnd.lotus-1-2-3"); - mimeTypes.put("fe_launch", "application/vnd.denovo.fcselayout-link"); - mimeTypes.put("setpay", "application/set-payment-initiation"); - mimeTypes.put("sdc", "application/vnd.stardivision.calc"); - mimeTypes.put("swi", "application/vnd.aristanetworks.swi"); - mimeTypes.put("g3", "image/g3fax"); - mimeTypes.put("cil", "application/vnd.ms-artgalry"); - mimeTypes.put("vcg", "application/vnd.groove-vcard"); - mimeTypes.put("chm", "application/vnd.ms-htmlhelp"); - mimeTypes.put("grxml", "application/srgs+xml"); - mimeTypes.put("ext", "application/vnd.novadigm.ext"); - mimeTypes.put("opf", "application/oebps-package+xml"); - mimeTypes.put("gtm", "application/vnd.groove-tool-message"); - mimeTypes.put("au", "audio/basic"); - mimeTypes.put("snd", "audio/basic"); - mimeTypes.put("ppsm", "application/vnd.ms-powerpoint.slideshow.macroenabled.12"); - mimeTypes.put("wbxml", "application/vnd.wap.wbxml"); - mimeTypes.put("oxt", "application/vnd.openofficeorg.extension"); - mimeTypes.put("davmount", "application/davmount+xml"); - mimeTypes.put("ivu", "application/vnd.immervision-ivu"); - mimeTypes.put("wrl", "model/vrml"); - mimeTypes.put("vrml", "model/vrml"); - mimeTypes.put("p7m", "application/pkcs7-mime"); - mimeTypes.put("p7c", "application/pkcs7-mime"); - mimeTypes.put("ppt", "application/vnd.ms-powerpoint"); - mimeTypes.put("pps", "application/vnd.ms-powerpoint"); - mimeTypes.put("pot", "application/vnd.ms-powerpoint"); - mimeTypes.put("ivp", "application/vnd.immervision-ivp"); - mimeTypes.put("movie", "video/x-sgi-movie"); - mimeTypes.put("ecelp4800", "audio/vnd.nuera.ecelp4800"); - mimeTypes.put("tpl", "application/vnd.groove-tool-template"); - mimeTypes.put("fnc", "application/vnd.frogans.fnc"); - mimeTypes.put("wax", "audio/x-ms-wax"); - mimeTypes.put("3gp", "video/3gpp"); - mimeTypes.put("ppd", "application/vnd.cups-ppd"); - mimeTypes.put("mmf", "application/vnd.smaf"); - mimeTypes.put("exe", "application/x-msdownload"); - mimeTypes.put("dll", "application/x-msdownload"); - mimeTypes.put("com", "application/x-msdownload"); - mimeTypes.put("bat", "application/x-msdownload"); - mimeTypes.put("msi", "application/x-msdownload"); - mimeTypes.put("skp", "application/vnd.koan"); - mimeTypes.put("skd", "application/vnd.koan"); - mimeTypes.put("skt", "application/vnd.koan"); - mimeTypes.put("skm", "application/vnd.koan"); - mimeTypes.put("ice", "x-conference/x-cooltalk"); - mimeTypes.put("emma", "application/emma+xml"); - mimeTypes.put("odc", "application/vnd.oasis.opendocument.chart"); - mimeTypes.put("atomcat", "application/atomcat+xml"); - mimeTypes.put("onetoc", "application/onenote"); - mimeTypes.put("onetoc2", "application/onenote"); - mimeTypes.put("onetmp", "application/onenote"); - mimeTypes.put("onepkg", "application/onenote"); - mimeTypes.put("otp", "application/vnd.oasis.opendocument.presentation-template"); - mimeTypes.put("irm", "application/vnd.ibm.rights-management"); - mimeTypes.put("texinfo", "application/x-texinfo"); - mimeTypes.put("texi", "application/x-texinfo"); - mimeTypes.put("spp", "application/scvp-vp-response"); - mimeTypes.put("xif", "image/vnd.xiff"); - mimeTypes.put("sitx", "application/x-stuffitx"); - mimeTypes.put("eol", "audio/vnd.digital-winds"); - mimeTypes.put("c4g", "application/vnd.clonk.c4group"); - mimeTypes.put("c4d", "application/vnd.clonk.c4group"); - mimeTypes.put("c4f", "application/vnd.clonk.c4group"); - mimeTypes.put("c4p", "application/vnd.clonk.c4group"); - mimeTypes.put("c4u", "application/vnd.clonk.c4group"); - mimeTypes.put("flo", "application/vnd.micrografx.flo"); - mimeTypes.put("svg", "image/svg+xml"); - mimeTypes.put("svgz", "image/svg+xml"); - mimeTypes.put("xsm", "application/vnd.syncml+xml"); - mimeTypes.put("hdf", "application/x-hdf"); - mimeTypes.put("cml", "chemical/x-cml"); - mimeTypes.put("atx", "application/vnd.antix.game-component"); - mimeTypes.put("flv", "video/x-flv"); - mimeTypes.put("m3u8", "application/vnd.apple.mpegurl"); - mimeTypes.put("wbs", "application/vnd.criticaltools.wbs+xml"); - mimeTypes.put("bz2", "application/x-bzip2"); - mimeTypes.put("boz", "application/x-bzip2"); - mimeTypes.put("plf", "application/vnd.pocketlearn"); - mimeTypes.put("lbe", "application/vnd.llamagraphics.life-balance.exchange+xml"); - mimeTypes.put("vcd", "application/x-cdlink"); - mimeTypes.put("sxg", "application/vnd.sun.xml.writer.global"); - mimeTypes.put("fli", "video/x-fli"); - mimeTypes.put("wsdl", "application/wsdl+xml"); - mimeTypes.put("slt", "application/vnd.epson.salt"); - mimeTypes.put("lwp", "application/vnd.lotus-wordpro"); - mimeTypes.put("ddd", "application/vnd.fujixerox.ddd"); - mimeTypes.put("xfdf", "application/vnd.adobe.xfdf"); - mimeTypes.put("portpkg", "application/vnd.macports.portpkg"); - mimeTypes.put("pfa", "application/x-font-type1"); - mimeTypes.put("pfb", "application/x-font-type1"); - mimeTypes.put("pfm", "application/x-font-type1"); - mimeTypes.put("afm", "application/x-font-type1"); - mimeTypes.put("nc", "application/x-netcdf"); - mimeTypes.put("cdf", "application/x-netcdf"); - mimeTypes.put("mpm", "application/vnd.blueice.multipass"); - mimeTypes.put("sis", "application/vnd.symbian.install"); - mimeTypes.put("sisx", "application/vnd.symbian.install"); - mimeTypes.put("ustar", "application/x-ustar"); - mimeTypes.put("rpst", "application/vnd.nokia.radio-preset"); - mimeTypes.put("eml", "message/rfc822"); - mimeTypes.put("mime", "message/rfc822"); - mimeTypes.put("g2w", "application/vnd.geoplan"); - mimeTypes.put("ma", "application/mathematica"); - mimeTypes.put("nb", "application/mathematica"); - mimeTypes.put("mb", "application/mathematica"); - mimeTypes.put("csv", "text/csv"); - mimeTypes.put("css", "text/css"); - mimeTypes.put("wvx", "video/x-ms-wvx"); - mimeTypes.put("jlt", "application/vnd.hp-jlyt"); - mimeTypes.put("vcx", "application/vnd.vcx"); - mimeTypes.put("html", "text/html"); - mimeTypes.put("htm", "text/html"); - mimeTypes.put("docm", "application/vnd.ms-word.document.macroenabled.12"); - mimeTypes.put("xdssc", "application/dssc+xml"); - mimeTypes.put("pbm", "image/x-binary-bitmap"); - mimeTypes.put("fdf", "application/vnd.fdf"); - mimeTypes.put("ggt", "application/vnd.geogebra.tool"); - mimeTypes.put("cii", "application/vnd.anser-web-certificate-issue-initiation"); - mimeTypes.put("atomsvc", "application/atomsvc+xml"); - mimeTypes.put("stw", "application/vnd.sun.xml.writer.template"); - mimeTypes.put("vtu", "model/vnd.vtu"); - mimeTypes.put("latex", "application/x-latex"); - mimeTypes.put("cat", "application/vnd.ms-pki.seccat"); - mimeTypes.put("odf", "application/vnd.oasis.opendocument.formula"); - mimeTypes.put("trm", "application/x-msterminal"); - mimeTypes.put("pptm", "application/vnd.ms-powerpoint.presentation.macroenabled.12"); - mimeTypes.put("stl", "application/vnd.ms-pki.stl"); - mimeTypes.put("ltf", "application/vnd.frogans.ltf"); - mimeTypes.put("obd", "application/x-msbinder"); - mimeTypes.put("sda", "application/vnd.stardivision.draw"); - mimeTypes.put("org", "application/vnd.lotus-organizer"); - mimeTypes.put("ftc", "application/vnd.fluxtime.clip"); - mimeTypes.put("rcprofile", "application/vnd.ipunplugged.rcprofile"); - mimeTypes.put("cmx", "image/x-cmx"); - mimeTypes.put("cif", "chemical/x-cif"); - mimeTypes.put("rp9", "application/vnd.cloanto.rp9"); - mimeTypes.put("pvb", "application/vnd.3gpp.pic-bw-var"); - mimeTypes.put("aw", "application/applixware"); - mimeTypes.put("pptx", "application/vnd.openxmlformats-officedocument.presentationml.presentation"); - mimeTypes.put("rld", "application/resource-lists-diff+xml"); - mimeTypes.put("xar", "application/vnd.xara"); - mimeTypes.put("ecelp7470", "audio/vnd.nuera.ecelp7470"); - mimeTypes.put("xls", "application/vnd.ms-excel"); - mimeTypes.put("xlm", "application/vnd.ms-excel"); - mimeTypes.put("xla", "application/vnd.ms-excel"); - mimeTypes.put("xlc", "application/vnd.ms-excel"); - mimeTypes.put("xlt", "application/vnd.ms-excel"); - mimeTypes.put("xlw", "application/vnd.ms-excel"); - mimeTypes.put("txf", "application/vnd.mobius.txf"); - mimeTypes.put("prc", "application/x-mobipocket-ebook"); - mimeTypes.put("mobi", "application/x-mobipocket-ebook"); - mimeTypes.put("swf", "application/x-shockwave-flash"); - mimeTypes.put("sfs", "application/vnd.spotfire.sfs"); - mimeTypes.put("dp", "application/vnd.osgi.dp"); - mimeTypes.put("potx", "application/vnd.openxmlformats-officedocument.presentationml.template"); - mimeTypes.put("efif", "application/vnd.picsel"); - mimeTypes.put("pdf", "application/pdf"); - mimeTypes.put("dsc", "text/prs.lines.tag"); - mimeTypes.put("mathml", "application/mathml+xml"); - mimeTypes.put("bed", "application/vnd.realvnc.bed"); - mimeTypes.put("bcpio", "application/x-bcpio"); - mimeTypes.put("shar", "application/x-shar"); - mimeTypes.put("xdm", "application/vnd.syncml.dm+xml"); - mimeTypes.put("teacher", "application/vnd.smart.teacher"); - mimeTypes.put("sldx", "application/vnd.openxmlformats-officedocument.presentationml.slide"); - mimeTypes.put("stf", "application/vnd.wt.stf"); - mimeTypes.put("odb", "application/vnd.oasis.opendocument.database"); - mimeTypes.put("bdf", "application/x-font-bdf"); - mimeTypes.put("tcap", "application/vnd.3gpp2.tcap"); - mimeTypes.put("fm", "application/vnd.framemaker"); - mimeTypes.put("frame", "application/vnd.framemaker"); - mimeTypes.put("maker", "application/vnd.framemaker"); - mimeTypes.put("book", "application/vnd.framemaker"); - mimeTypes.put("src", "application/x-wais-source"); - mimeTypes.put("rep", "application/vnd.businessobjects"); - mimeTypes.put("dna", "application/vnd.dna"); - mimeTypes.put("jpgv", "video/jpeg"); - mimeTypes.put("ez", "application/andrew-inset"); - mimeTypes.put("vxml", "application/voicexml+xml"); - mimeTypes.put("x3d", "application/vnd.hzn-3d-crossword"); - mimeTypes.put("dxp", "application/vnd.spotfire.dxp"); - mimeTypes.put("dvi", "application/x-dvi"); - mimeTypes.put("f4v", "video/x-f4v"); - mimeTypes.put("fg5", "application/vnd.fujitsu.oasysgp"); - mimeTypes.put("clp", "application/x-msclip"); - mimeTypes.put("acu", "application/vnd.acucobol"); - mimeTypes.put("ksp", "application/vnd.kde.kspread"); - mimeTypes.put("rms", "application/vnd.jcp.javame.midlet-rms"); - mimeTypes.put("lvp", "audio/vnd.lucent.voice"); - mimeTypes.put("jpm", "video/jpm"); - mimeTypes.put("jpgm", "video/jpm"); - mimeTypes.put("pcx", "image/x-pcx"); - mimeTypes.put("sxm", "application/vnd.sun.xml.math"); - mimeTypes.put("g3w", "application/vnd.geospace"); - mimeTypes.put("ngdat", "application/vnd.nokia.n-gage.data"); - mimeTypes.put("clkp", "application/vnd.crick.clicker.palette"); - mimeTypes.put("osfpvg", "application/vnd.yamaha.openscoreformat.osfpvg+xml"); - mimeTypes.put("aep", "application/vnd.audiograph"); - mimeTypes.put("wqd", "application/vnd.wqd"); - mimeTypes.put("mdi", "image/vnd.ms-modi"); - mimeTypes.put("ecelp9600", "audio/vnd.nuera.ecelp9600"); - mimeTypes.put("fig", "application/x-xfig"); - mimeTypes.put("p7r", "application/x-pkcs7-certreqresp"); - mimeTypes.put("jar", "application/java-archive"); - mimeTypes.put("ief", "image/ief"); - mimeTypes.put("hvs", "application/vnd.yamaha.hv-script"); - mimeTypes.put("cdx", "chemical/x-cdx"); - mimeTypes.put("abw", "application/x-abiword"); - mimeTypes.put("deb", "application/x-debian-package"); - mimeTypes.put("udeb", "application/x-debian-package"); - mimeTypes.put("djvu", "image/vnd.djvu"); - mimeTypes.put("djv", "image/vnd.djvu"); - mimeTypes.put("wml", "text/vnd.wap.wml"); - mimeTypes.put("xhtml", "application/xhtml+xml"); - mimeTypes.put("xht", "application/xhtml+xml"); - mimeTypes.put("tpt", "application/vnd.trid.tpt"); - mimeTypes.put("wmz", "application/x-ms-wmz"); - mimeTypes.put("rtx", "text/richtext"); - mimeTypes.put("wspolicy", "application/wspolicy+xml"); - mimeTypes.put("odg", "application/vnd.oasis.opendocument.graphics"); - mimeTypes.put("res", "application/x-dtbresource+xml"); - mimeTypes.put("xbm", "image/x-xbitmap"); - mimeTypes.put("zir", "application/vnd.zul"); - mimeTypes.put("zirz", "application/vnd.zul"); - mimeTypes.put("cdkey", "application/vnd.mediastation.cdkey"); - mimeTypes.put("wmd", "application/x-ms-wmd"); - mimeTypes.put("ogv", "video/ogg"); - mimeTypes.put("scq", "application/scvp-cv-request"); - mimeTypes.put("sfd-hdstx", "application/vnd.hydrostatix.sof-data"); - mimeTypes.put("igx", "application/vnd.micrografx.igx"); - mimeTypes.put("xps", "application/vnd.ms-xpsdocument"); - mimeTypes.put("xdw", "application/vnd.fujixerox.docuworks"); - mimeTypes.put("kfo", "application/vnd.kde.kformula"); - mimeTypes.put("chrt", "application/vnd.kde.kchart"); - mimeTypes.put("sdp", "application/sdp"); - mimeTypes.put("oth", "application/vnd.oasis.opendocument.text-web"); - mimeTypes.put("3g2", "video/3gpp2"); - mimeTypes.put("utz", "application/vnd.uiq.theme"); - mimeTypes.put("mus", "application/vnd.musician"); - mimeTypes.put("wpd", "application/vnd.wordperfect"); - mimeTypes.put("oas", "application/vnd.fujitsu.oasys"); - mimeTypes.put("pic", "image/x-pict"); - mimeTypes.put("pct", "image/x-pict"); - mimeTypes.put("wmx", "video/x-ms-wmx"); - mimeTypes.put("p10", "application/pkcs10"); - mimeTypes.put("wmv", "video/x-ms-wmv"); - mimeTypes.put("xfdl", "application/vnd.xfdl"); - mimeTypes.put("pgp", "application/pgp-encrypted"); - mimeTypes.put("rs", "application/rls-services+xml"); - mimeTypes.put("cpt", "application/mac-compactpro"); - mimeTypes.put("gmx", "application/vnd.gmx"); - mimeTypes.put("potm", "application/vnd.ms-powerpoint.template.macroenabled.12"); - mimeTypes.put("iif", "application/vnd.shana.informed.interchange"); - mimeTypes.put("ace", "application/x-ace-compressed"); - mimeTypes.put("pcurl", "application/vnd.curl.pcurl"); - mimeTypes.put("ods", "application/vnd.oasis.opendocument.spreadsheet"); - mimeTypes.put("vsd", "application/vnd.visio"); - mimeTypes.put("vst", "application/vnd.visio"); - mimeTypes.put("vss", "application/vnd.visio"); - mimeTypes.put("vsw", "application/vnd.visio"); - mimeTypes.put("ifm", "application/vnd.shana.informed.formdata"); - mimeTypes.put("fbs", "image/vnd.fastbidsheet"); - mimeTypes.put("qxd", "application/vnd.quark.quarkxpress"); - mimeTypes.put("qxt", "application/vnd.quark.quarkxpress"); - mimeTypes.put("qwd", "application/vnd.quark.quarkxpress"); - mimeTypes.put("qwt", "application/vnd.quark.quarkxpress"); - mimeTypes.put("qxl", "application/vnd.quark.quarkxpress"); - mimeTypes.put("qxb", "application/vnd.quark.quarkxpress"); - mimeTypes.put("epub", "application/epub+zip"); - mimeTypes.put("crl", "application/pkix-crl"); - mimeTypes.put("nnw", "application/vnd.noblenet-web"); - mimeTypes.put("nbp", "application/vnd.wolfram.player"); - mimeTypes.put("plb", "application/vnd.3gpp.pic-bw-large"); - mimeTypes.put("itp", "application/vnd.shana.informed.formtemplate"); - mimeTypes.put("snf", "application/x-font-snf"); - mimeTypes.put("str", "application/vnd.pg.format"); - mimeTypes.put("wtb", "application/vnd.webturbo"); - mimeTypes.put("osf", "application/vnd.yamaha.openscoreformat"); - mimeTypes.put("xltx", "application/vnd.openxmlformats-officedocument.spreadsheetml.template"); - mimeTypes.put("pre", "application/vnd.lotus-freelance"); - mimeTypes.put("clkt", "application/vnd.crick.clicker.template"); - mimeTypes.put("hbci", "application/vnd.hbci"); - mimeTypes.put("dwf", "model/vnd.dwf"); - mimeTypes.put("igs", "model/iges"); - mimeTypes.put("iges", "model/iges"); - mimeTypes.put("ktz", "application/vnd.kahootz"); - mimeTypes.put("ktr", "application/vnd.kahootz"); - mimeTypes.put("n-gage", "application/vnd.nokia.n-gage.symbian.install"); - mimeTypes.put("otg", "application/vnd.oasis.opendocument.graphics-template"); - mimeTypes.put("rsd", "application/rsd+xml"); - mimeTypes.put("hlp", "application/winhlp"); - mimeTypes.put("azw", "application/vnd.amazon.ebook"); - mimeTypes.put("msf", "application/vnd.epson.msf"); - mimeTypes.put("mp4", "video/mp4"); - mimeTypes.put("mp4v", "video/mp4"); - mimeTypes.put("mpg4", "video/mp4"); - mimeTypes.put("cod", "application/vnd.rim.cod"); - mimeTypes.put("st", "application/vnd.sailingtracker.track"); - mimeTypes.put("odi", "application/vnd.oasis.opendocument.image"); - mimeTypes.put("tra", "application/vnd.trueapp"); - mimeTypes.put("wm", "video/x-ms-wm"); - mimeTypes.put("bin", "application/octet-stream"); - mimeTypes.put("dms", "application/octet-stream"); - mimeTypes.put("lha", "application/octet-stream"); - mimeTypes.put("lrf", "application/octet-stream"); - mimeTypes.put("lzh", "application/octet-stream"); - mimeTypes.put("so", "application/octet-stream"); - mimeTypes.put("iso", "application/octet-stream"); - mimeTypes.put("dmg", "application/octet-stream"); - mimeTypes.put("dist", "application/octet-stream"); - mimeTypes.put("distz", "application/octet-stream"); - mimeTypes.put("pkg", "application/octet-stream"); - mimeTypes.put("bpk", "application/octet-stream"); - mimeTypes.put("dump", "application/octet-stream"); - mimeTypes.put("elc", "application/octet-stream"); - mimeTypes.put("deploy", "application/octet-stream"); - mimeTypes.put("tsv", "text/tab-separated-values"); - mimeTypes.put("esf", "application/vnd.epson.esf"); - mimeTypes.put("p7s", "application/pkcs7-signature"); - mimeTypes.put("xlsx", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); - mimeTypes.put("geo", "application/vnd.dynageo"); - mimeTypes.put("mmd", "application/vnd.chipnuts.karaoke-mmd"); - mimeTypes.put("mxml", "application/xv+xml"); - mimeTypes.put("xhvml", "application/xv+xml"); - mimeTypes.put("xvml", "application/xv+xml"); - mimeTypes.put("xvm", "application/xv+xml"); - mimeTypes.put("nsf", "application/vnd.lotus-notes"); - mimeTypes.put("crd", "application/x-mscardfile"); - mimeTypes.put("p12", "application/x-pkcs12"); - mimeTypes.put("pfx", "application/x-pkcs12"); - mimeTypes.put("c", "text/x-c"); - mimeTypes.put("cc", "text/x-c"); - mimeTypes.put("cxx", "text/x-c"); - mimeTypes.put("cpp", "text/x-c"); - mimeTypes.put("h", "text/x-c"); - mimeTypes.put("hh", "text/x-c"); - mimeTypes.put("dic", "text/x-c"); - mimeTypes.put("cla", "application/vnd.claymore"); - mimeTypes.put("avi", "video/x-msvideo"); - mimeTypes.put("edx", "application/vnd.novadigm.edx"); - mimeTypes.put("gph", "application/vnd.flographit"); - mimeTypes.put("rq", "application/sparql-query"); - mimeTypes.put("xdp", "application/vnd.adobe.xdp+xml"); - mimeTypes.put("umj", "application/vnd.umajin"); - mimeTypes.put("pclxl", "application/vnd.hp-pclxl"); - mimeTypes.put("edm", "application/vnd.novadigm.edm"); - mimeTypes.put("gif", "image/gif"); - mimeTypes.put("jpeg", "image/jpeg"); - mimeTypes.put("jpg", "image/jpeg"); - mimeTypes.put("jpe", "image/jpeg"); - mimeTypes.put("adp", "audio/adpcm"); - mimeTypes.put("txt", "text/plain"); - mimeTypes.put("text", "text/plain"); - mimeTypes.put("conf", "text/plain"); - mimeTypes.put("def", "text/plain"); - mimeTypes.put("list", "text/plain"); - mimeTypes.put("log", "text/plain"); - mimeTypes.put("in", "text/plain"); - mimeTypes.put("gsf", "application/x-font-ghostscript"); - mimeTypes.put("aab", "application/x-authorware-bin"); - mimeTypes.put("x32", "application/x-authorware-bin"); - mimeTypes.put("u32", "application/x-authorware-bin"); - mimeTypes.put("vox", "application/x-authorware-bin"); - mimeTypes.put("ott", "application/vnd.oasis.opendocument.text-template"); - mimeTypes.put("kmz", "application/vnd.google-earth.kmz"); - mimeTypes.put("etx", "text/x-setext"); - mimeTypes.put("sv4crc", "application/x-sv4crc"); - mimeTypes.put("xlam", "application/vnd.ms-excel.addin.macroenabled.12"); - mimeTypes.put("pcf", "application/x-font-pcf"); - mimeTypes.put("torrent", "application/x-bittorrent"); - mimeTypes.put("twd", "application/vnd.simtech-mindmapper"); - mimeTypes.put("twds", "application/vnd.simtech-mindmapper"); - mimeTypes.put("qam", "application/vnd.epson.quickanime"); - mimeTypes.put("bdm", "application/vnd.syncml.dm+wbxml"); - mimeTypes.put("3dml", "text/vnd.in3d.3dml"); - mimeTypes.put("saf", "application/vnd.yamaha.smaf-audio"); - mimeTypes.put("ncx", "application/x-dtbncx+xml"); - mimeTypes.put("ppsx", "application/vnd.openxmlformats-officedocument.presentationml.slideshow"); - mimeTypes.put("sc", "application/vnd.ibm.secure-container"); - mimeTypes.put("gnumeric", "application/x-gnumeric"); - mimeTypes.put("paw", "application/vnd.pawaafile"); - mimeTypes.put("bmp", "image/bmp"); - mimeTypes.put("bmi", "application/vnd.bmi"); - mimeTypes.put("sxc", "application/vnd.sun.xml.calc"); - mimeTypes.put("gim", "application/vnd.groove-identity-message"); - mimeTypes.put("qps", "application/vnd.publishare-delta-tree"); - mimeTypes.put("scd", "application/x-msschedule"); - mimeTypes.put("mgz", "application/vnd.proteus.magazine"); - mimeTypes.put("vcf", "text/x-vcard"); - mimeTypes.put("flw", "application/vnd.kde.kivio"); - mimeTypes.put("xslt", "application/xslt+xml"); - mimeTypes.put("stc", "application/vnd.sun.xml.calc.template"); - mimeTypes.put("dir", "application/x-director"); - mimeTypes.put("dcr", "application/x-director"); - mimeTypes.put("dxr", "application/x-director"); - mimeTypes.put("cst", "application/x-director"); - mimeTypes.put("cct", "application/x-director"); - mimeTypes.put("cxt", "application/x-director"); - mimeTypes.put("w3d", "application/x-director"); - mimeTypes.put("fgd", "application/x-director"); - mimeTypes.put("swa", "application/x-director"); - mimeTypes.put("rif", "application/reginfo+xml"); - mimeTypes.put("atc", "application/vnd.acucorp"); - mimeTypes.put("acutc", "application/vnd.acucorp"); - mimeTypes.put("fti", "application/vnd.anser-web-funds-transfer-initiation"); - mimeTypes.put("dis", "application/vnd.mobius.dis"); - mimeTypes.put("zmm", "application/vnd.handheld-entertainment+xml"); - mimeTypes.put("mag", "application/vnd.ecowin.chart"); - mimeTypes.put("mlp", "application/vnd.dolby.mlp"); - mimeTypes.put("psb", "application/vnd.3gpp.pic-bw-small"); - mimeTypes.put("mdb", "application/x-msaccess"); - mimeTypes.put("aso", "application/vnd.accpac.simply.aso"); - mimeTypes.put("pwn", "application/vnd.3m.post-it-notes"); - mimeTypes.put("ots", "application/vnd.oasis.opendocument.spreadsheet-template"); - mimeTypes.put("mj2", "video/mj2"); - mimeTypes.put("mjp2", "video/mj2"); - mimeTypes.put("link66", "application/vnd.route66.link66+xml"); - mimeTypes.put("les", "application/vnd.hhe.lesson-player"); - mimeTypes.put("sti", "application/vnd.sun.xml.impress.template"); - mimeTypes.put("cdbcmsg", "application/vnd.contact.cmsg"); - mimeTypes.put("cdxml", "application/vnd.chemdraw+xml"); - mimeTypes.put("aac", "audio/x-aac"); - mimeTypes.put("ipfix", "application/ipfix"); - mimeTypes.put("mxu", "video/vnd.mpegurl"); - mimeTypes.put("m4u", "video/vnd.mpegurl"); - mimeTypes.put("cer", "application/pkix-cert"); - mimeTypes.put("mny", "application/x-msmoney"); - mimeTypes.put("tex", "application/x-tex"); - mimeTypes.put("ics", "text/calendar"); - mimeTypes.put("ifb", "text/calendar"); - mimeTypes.put("ei6", "application/vnd.pg.osasli"); - mimeTypes.put("spf", "application/vnd.yamaha.smaf-phrase"); - mimeTypes.put("lostxml", "application/lost+xml"); - mimeTypes.put("apk", "application/vnd.android.package-archive"); - mimeTypes.put("pub", "application/x-mspublisher"); - mimeTypes.put("gtw", "model/vnd.gtw"); - mimeTypes.put("ufd", "application/vnd.ufdl"); - mimeTypes.put("ufdl", "application/vnd.ufdl"); - mimeTypes.put("jnlp", "application/x-java-jnlp-file"); - mimeTypes.put("air", "application/vnd.adobe.air-application-installer-package+zip"); - mimeTypes.put("dcurl", "text/vnd.curl.dcurl"); - mimeTypes.put("mxl", "application/vnd.recordare.musicxml"); - mimeTypes.put("cpio", "application/x-cpio"); - mimeTypes.put("mpp", "application/vnd.ms-project"); - mimeTypes.put("mpt", "application/vnd.ms-project"); - mimeTypes.put("pdb", "application/vnd.palm"); - mimeTypes.put("pqa", "application/vnd.palm"); - mimeTypes.put("oprc", "application/vnd.palm"); - mimeTypes.put("mrc", "application/marc"); - mimeTypes.put("hqx", "application/mac-binhex40"); - mimeTypes.put("json", "application/json"); - mimeTypes.put("mvb", "application/x-msmediaview"); - mimeTypes.put("m13", "application/x-msmediaview"); - mimeTypes.put("m14", "application/x-msmediaview"); - mimeTypes.put("mpga", "audio/mpeg"); - mimeTypes.put("mp2", "audio/mpeg"); - mimeTypes.put("mp2a", "audio/mpeg"); - mimeTypes.put("mp3", "audio/mpeg"); - mimeTypes.put("m2a", "audio/mpeg"); - mimeTypes.put("m3a", "audio/mpeg"); - mimeTypes.put("cmc", "application/vnd.cosmocaller"); - mimeTypes.put("wmf", "application/x-msmetafile"); - mimeTypes.put("odft", "application/vnd.oasis.opendocument.formula-template"); - mimeTypes.put("dtb", "application/x-dtbook+xml"); - mimeTypes.put("xbap", "application/x-ms-xbap"); - mimeTypes.put("csp", "application/vnd.commonspace"); - mimeTypes.put("stk", "application/hyperstudio"); - mimeTypes.put("mpn", "application/vnd.mophun.application"); - mimeTypes.put("gqf", "application/vnd.grafeq"); - mimeTypes.put("gqs", "application/vnd.grafeq"); - mimeTypes.put("rl", "application/resource-lists+xml"); - mimeTypes.put("gtar", "application/x-gtar"); - mimeTypes.put("pls", "application/pls+xml"); - mimeTypes.put("tcl", "application/x-tcl"); - mimeTypes.put("der", "application/x-x509-ca-cert"); - mimeTypes.put("crt", "application/x-x509-ca-cert"); - mimeTypes.put("xo", "application/vnd.olpc-sugar"); - mimeTypes.put("xltm", "application/vnd.ms-excel.template.macroenabled.12"); - mimeTypes.put("cu", "application/cu-seeme"); - mimeTypes.put("kml", "application/vnd.google-earth.kml+xml"); - mimeTypes.put("sh", "application/x-sh"); - mimeTypes.put("xpw", "application/vnd.intercon.formnet"); - mimeTypes.put("xpx", "application/vnd.intercon.formnet"); - mimeTypes.put("wg", "application/vnd.pmi.widget"); - mimeTypes.put("seed", "application/vnd.fdsn.seed"); - mimeTypes.put("dataless", "application/vnd.fdsn.seed"); - mimeTypes.put("sdd", "application/vnd.stardivision.impress"); - mimeTypes.put("ttf", "application/x-font-ttf"); - mimeTypes.put("ttc", "application/x-font-ttf"); - mimeTypes.put("npx", "image/vnd.net-fpx"); - mimeTypes.put("aif", "audio/x-aiff"); - mimeTypes.put("aiff", "audio/x-aiff"); - mimeTypes.put("aifc", "audio/x-aiff"); - mimeTypes.put("xlsb", "application/vnd.ms-excel.sheet.binary.macroenabled.12"); - mimeTypes.put("wbmp", "image/vnd.wap.wbmp"); - mimeTypes.put("rtf", "application/rtf"); - mimeTypes.put("sus", "application/vnd.sus-calendar"); - mimeTypes.put("susp", "application/vnd.sus-calendar"); - mimeTypes.put("prf", "application/pics-rules"); - mimeTypes.put("tar", "application/x-tar"); - mimeTypes.put("pml", "application/vnd.ctc-posml"); - mimeTypes.put("ims", "application/vnd.ms-ims"); - mimeTypes.put("imp", "application/vnd.accpac.simply.imp"); - mimeTypes.put("xul", "application/vnd.mozilla.xul+xml"); - mimeTypes.put("acc", "application/vnd.americandynamics.acc"); - mimeTypes.put("mfm", "application/vnd.mfmp"); - mimeTypes.put("dotm", "application/vnd.ms-word.template.macroenabled.12"); - mimeTypes.put("ptid", "application/vnd.pvi.ptid1"); - mimeTypes.put("pyv", "video/vnd.ms-playready.media.pyv"); - mimeTypes.put("ssf", "application/vnd.epson.ssf"); - mimeTypes.put("sxd", "application/vnd.sun.xml.draw"); - mimeTypes.put("xap", "application/x-silverlight-app"); - mimeTypes.put("fst", "image/vnd.fst"); - mimeTypes.put("rdf", "application/rdf+xml"); - mimeTypes.put("gv", "text/vnd.graphviz"); - mimeTypes.put("lrm", "application/vnd.ms-lrm"); - mimeTypes.put("box", "application/vnd.previewsystems.box"); - mimeTypes.put("mseq", "application/vnd.mseq"); - mimeTypes.put("xwd", "image/x-xwindowdump"); - mimeTypes.put("mscml", "application/mediaservercontrol+xml"); - mimeTypes.put("cmp", "application/vnd.yellowriver-custom-menu"); - mimeTypes.put("wad", "application/x-doom"); - mimeTypes.put("svd", "application/vnd.svd"); - mimeTypes.put("pki", "application/pkixcmp"); - mimeTypes.put("ai", "application/postscript"); - mimeTypes.put("eps", "application/postscript"); - mimeTypes.put("ps", "application/postscript"); - mimeTypes.put("msl", "application/vnd.mobius.msl"); - mimeTypes.put("sv4cpio", "application/x-sv4cpio"); - mimeTypes.put("java", "text/x-java-source"); - mimeTypes.put("mpc", "application/vnd.mophun.certificate"); - mimeTypes.put("daf", "application/vnd.mobius.daf"); - mimeTypes.put("qfx", "application/vnd.intu.qfx"); - mimeTypes.put("mxf", "application/mxf"); - mimeTypes.put("mif", "application/vnd.mif"); - mimeTypes.put("txd", "application/vnd.genomatix.tuxedo"); - mimeTypes.put("pkipath", "application/pkix-pkipath"); - mimeTypes.put("sse", "application/vnd.kodak-descriptor"); - mimeTypes.put("kon", "application/vnd.kde.kontour"); - mimeTypes.put("dfac", "application/vnd.dreamfactory"); - mimeTypes.put("gram", "application/srgs"); - mimeTypes.put("hps", "application/vnd.hp-hps"); - mimeTypes.put("cab", "application/vnd.ms-cab-compressed"); - mimeTypes.put("m3u", "audio/x-mpegurl"); - mimeTypes.put("odp", "application/vnd.oasis.opendocument.presentation"); - mimeTypes.put("ggb", "application/vnd.geogebra.file"); - mimeTypes.put("xyz", "chemical/x-xyz"); - mimeTypes.put("clkw", "application/vnd.crick.clicker.wordbank"); - mimeTypes.put("mqy", "application/vnd.mobius.mqy"); - mimeTypes.put("ico", "image/x-icon"); - mimeTypes.put("png", "image/png"); - mimeTypes.put("wmlc", "application/vnd.wap.wmlc"); - mimeTypes.put("kne", "application/vnd.kinar"); - mimeTypes.put("knp", "application/vnd.kinar"); - mimeTypes.put("kpr", "application/vnd.kde.kpresenter"); - mimeTypes.put("kpt", "application/vnd.kde.kpresenter"); - mimeTypes.put("sbml", "application/sbml+xml"); - mimeTypes.put("fpx", "image/vnd.fpx"); - mimeTypes.put("bz", "application/x-bzip"); - mimeTypes.put("flx", "text/vnd.fmi.flexstor"); - mimeTypes.put("application", "application/x-ms-application"); - mimeTypes.put("wmlsc", "application/vnd.wap.wmlscriptc"); - mimeTypes.put("lbd", "application/vnd.llamagraphics.life-balance.desktop"); - mimeTypes.put("sxw", "application/vnd.sun.xml.writer"); - mimeTypes.put("jam", "application/vnd.jam"); - mimeTypes.put("musicxml", "application/vnd.recordare.musicxml+xml"); - mimeTypes.put("see", "application/vnd.seemail"); - mimeTypes.put("irp", "application/vnd.irepository.package+xml"); - mimeTypes.put("tiff", "image/tiff"); - mimeTypes.put("tif", "image/tiff"); - mimeTypes.put("aam", "application/x-authorware-map"); - mimeTypes.put("chat", "application/x-chat"); - mimeTypes.put("mpkg", "application/vnd.apple.installer+xml"); - mimeTypes.put("otc", "application/vnd.oasis.opendocument.chart-template"); - mimeTypes.put("msh", "model/mesh"); - mimeTypes.put("mesh", "model/mesh"); - mimeTypes.put("silo", "model/mesh"); - mimeTypes.put("t", "text/troff"); - mimeTypes.put("tr", "text/troff"); - mimeTypes.put("roff", "text/troff"); - mimeTypes.put("man", "text/troff"); - mimeTypes.put("me", "text/troff"); - mimeTypes.put("ms", "text/troff"); - mimeTypes.put("dpg", "application/vnd.dpgraph"); - mimeTypes.put("wri", "application/x-mswrite"); - mimeTypes.put("dts", "audio/vnd.dts"); - mimeTypes.put("xpi", "application/x-xpinstall"); - mimeTypes.put("ram", "audio/x-pn-realaudio"); - mimeTypes.put("ra", "audio/x-pn-realaudio"); - mimeTypes.put("sdkm", "application/vnd.solent.sdkm+xml"); - mimeTypes.put("sdkd", "application/vnd.solent.sdkm+xml"); - mimeTypes.put("dtshd", "audio/vnd.dts.hd"); - mimeTypes.put("btif", "image/prs.btif"); - mimeTypes.put("scs", "application/scvp-cv-response"); - mimeTypes.put("car", "application/vnd.curl.car"); - mimeTypes.put("otf", "application/x-font-otf"); - mimeTypes.put("clkx", "application/vnd.crick.clicker"); - mimeTypes.put("xbd", "application/vnd.fujixerox.docuworks.binder"); - mimeTypes.put("ppm", "image/x-binary-pixmap"); - mimeTypes.put("wav", "audio/x-wav"); - mimeTypes.put("ssml", "application/ssml+xml"); - mimeTypes.put("p7b", "application/x-pkcs7-certificates"); - mimeTypes.put("spc", "application/x-pkcs7-certificates"); - mimeTypes.put("kia", "application/vnd.kidspiration"); - mimeTypes.put("rss", "application/rss+xml"); - mimeTypes.put("setreg", "application/set-registration-initiation"); - mimeTypes.put("qbo", "application/vnd.intu.qbo"); - mimeTypes.put("ras", "image/x-cmu-raster"); - mimeTypes.put("rar", "application/x-rar-compressed"); - mimeTypes.put("ogx", "application/ogg"); - mimeTypes.put("class", "application/java-vm"); - mimeTypes.put("smf", "application/vnd.stardivision.math"); - mimeTypes.put("atom", "application/atom+xml"); - mimeTypes.put("sit", "application/x-stuffit"); - mimeTypes.put("ez3", "application/vnd.ezpix-package"); - mimeTypes.put("mcurl", "text/vnd.curl.mcurl"); - mimeTypes.put("wmls", "text/vnd.wap.wmlscript"); - mimeTypes.put("srx", "application/sparql-results+xml"); - mimeTypes.put("wps", "application/vnd.ms-works"); - mimeTypes.put("wks", "application/vnd.ms-works"); - mimeTypes.put("wcm", "application/vnd.ms-works"); - mimeTypes.put("wdb", "application/vnd.ms-works"); - mimeTypes.put("vcs", "text/x-vcalendar"); - mimeTypes.put("ecma", "application/ecmascript"); - mimeTypes.put("curl", "text/vnd.curl"); - mimeTypes.put("std", "application/vnd.sun.xml.draw.template"); - mimeTypes.put("eot", "application/vnd.ms-fontobject"); - mimeTypes.put("fsc", "application/vnd.fsc.weblaunch"); - mimeTypes.put("tfm", "application/x-tex-tfm"); - mimeTypes.put("dra", "audio/vnd.dra"); - mimeTypes.put("mwf", "application/vnd.mfer"); - mimeTypes.put("hpid", "application/vnd.hp-hpid"); - mimeTypes.put("nml", "application/vnd.enliven"); - mimeTypes.put("hvp", "application/vnd.yamaha.hv-voice"); - mimeTypes.put("s", "text/x-asm"); - mimeTypes.put("asm", "text/x-asm"); - mimeTypes.put("mcd", "application/vnd.mcd"); - mimeTypes.put("mts", "model/vnd.mts"); - mimeTypes.put("igl", "application/vnd.igloader"); - mimeTypes.put("tao", "application/vnd.tao.intent-module-archive"); - mimeTypes.put("sgml", "text/sgml"); - mimeTypes.put("sgm", "text/sgml"); - mimeTypes.put("rmp", "audio/x-pn-realaudio-plugin"); - mimeTypes.put("xenc", "application/xenc+xml"); - mimeTypes.put("wpl", "application/vnd.ms-wpl"); - mimeTypes.put("dxf", "image/vnd.dxf"); - mimeTypes.put("pgm", "image/x-binary-graymap"); - mimeTypes.put("spot", "text/vnd.in3d.spot"); - mimeTypes.put("odt", "application/vnd.oasis.opendocument.text"); - mimeTypes.put("azs", "application/vnd.airzip.filesecure.azs"); - mimeTypes.put("es3", "application/vnd.eszigno3+xml"); - mimeTypes.put("et3", "application/vnd.eszigno3+xml"); - mimeTypes.put("dd2", "application/vnd.oma.dd2+xml"); - mimeTypes.put("semf", "application/vnd.semf"); - mimeTypes.put("semd", "application/vnd.semd"); - mimeTypes.put("pnm", "image/x-binary-anymap"); - mimeTypes.put("sema", "application/vnd.sema"); - mimeTypes.put("wma", "audio/x-ms-wma"); - mimeTypes.put("cww", "application/prs.cww"); - mimeTypes.put("scm", "application/vnd.lotus-screencam"); - mimeTypes.put("azf", "application/vnd.airzip.filesecure.azf"); - mimeTypes.put("oda", "application/oda"); - mimeTypes.put("dwg", "image/vnd.dwg"); - mimeTypes.put("h264", "video/h264"); - mimeTypes.put("hpgl", "application/vnd.hp-hpgl"); - mimeTypes.put("xpr", "application/vnd.is-xpr"); - mimeTypes.put("h263", "video/h263"); - mimeTypes.put("zip", "application/zip"); - mimeTypes.put("h261", "video/h261"); - mimeTypes.put("oti", "application/vnd.oasis.opendocument.image-template"); - mimeTypes.put("uoml", "application/vnd.uoml+xml"); - mimeTypes.put("xspf", "application/xspf+xml"); - mimeTypes.put("ppam", "application/vnd.ms-powerpoint.addin.macroenabled.12"); - mimeTypes.put("dtd", "application/xml-dtd"); - mimeTypes.put("gex", "application/vnd.geometry-explorer"); - mimeTypes.put("gre", "application/vnd.geometry-explorer"); - mimeTypes.put("dssc", "application/dssc+der"); - } - - /** - * @param f File to detect content type. - * @return Content type. - */ - @Nullable public static String getContentType(File f) { - try (FileInputStream is = new FileInputStream(f)) { - byte[] data = new byte[Math.min((int)f.length(), PREVIEW_SIZE)]; - - is.read(data); - - return getContentType(data, f.getName()); - } - catch (IOException ignored) { - return null; - } - } - - /** - * @param data Bytes to detect content type. - * @param name File name to detect content type by file name. - * @return Content type. - */ - @Nullable public static String getContentType(byte[] data, String name) { - if (data == null) - return null; - - byte[] hdr = new byte[PREVIEW_SIZE]; - - System.arraycopy(data, 0, hdr, 0, Math.min(data.length, hdr.length)); - - int c1 = hdr[0] & 0xff; - int c2 = hdr[1] & 0xff; - int c3 = hdr[2] & 0xff; - int c4 = hdr[3] & 0xff; - int c5 = hdr[4] & 0xff; - int c6 = hdr[5] & 0xff; - int c7 = hdr[6] & 0xff; - int c8 = hdr[7] & 0xff; - int c9 = hdr[8] & 0xff; - int c10 = hdr[9] & 0xff; - int c11 = hdr[10] & 0xff; - - if (c1 == 0xCA && c2 == 0xFE && c3 == 0xBA && c4 == 0xBE) - return "application/java-vm"; - - if (c1 == 0xD0 && c2 == 0xCF && c3 == 0x11 && c4 == 0xE0 && c5 == 0xA1 && c6 == 0xB1 && c7 == 0x1A && c8 == 0xE1) { - // if the name is set then check if it can be validated by name, because it could be a xls or powerpoint - String contentType = guessContentTypeFromName(name); - - if (contentType != null) - return contentType; - - return "application/msword"; - } - if (c1 == 0x25 && c2 == 0x50 && c3 == 0x44 && c4 == 0x46 && c5 == 0x2d && c6 == 0x31 && c7 == 0x2e) - return "application/pdf"; - - if (c1 == 0x38 && c2 == 0x42 && c3 == 0x50 && c4 == 0x53 && c5 == 0x00 && c6 == 0x01) - return "image/photoshop"; - - if (c1 == 0x25 && c2 == 0x21 && c3 == 0x50 && c4 == 0x53) - return "application/postscript"; - - if (c1 == 0xff && c2 == 0xfb && c3 == 0x30) - return "audio/mp3"; - - if (c1 == 0x49 && c2 == 0x44 && c3 == 0x33) - return "audio/mp3"; - - if (c1 == 0xAC && c2 == 0xED) { - // next two bytes are version number, currently 0x00 0x05 - return "application/x-java-serialized-object"; - } - - if (c1 == '<') { - if (c2 == '!' || - ((c2 == 'h' && (c3 == 't' && c4 == 'm' && c5 == 'l' || c3 == 'e' && c4 == 'a' && c5 == 'd') || - (c2 == 'b' && c3 == 'o' && c4 == 'd' && c5 == 'y'))) || - ((c2 == 'H' && (c3 == 'T' && c4 == 'M' && c5 == 'L' || c3 == 'E' && c4 == 'A' && c5 == 'D') || - (c2 == 'B' && c3 == 'O' && c4 == 'D' && c5 == 'Y')))) - return "text/html"; - - if (c2 == '?' && c3 == 'x' && c4 == 'm' && c5 == 'l' && c6 == ' ') - return "application/xml"; - } - - // big and little endian UTF-16 encodings, with byte order mark - if (c1 == 0xfe && c2 == 0xff) { - if (c3 == 0 && c4 == '<' && c5 == 0 && c6 == '?' && c7 == 0 && c8 == 'x') - return "application/xml"; - } - - if (c1 == 0xff && c2 == 0xfe) { - if (c3 == '<' && c4 == 0 && c5 == '?' && c6 == 0 && c7 == 'x' && c8 == 0) - return "application/xml"; - } - - if (c1 == 'B' && c2 == 'M') - return "image/bmp"; - - if (c1 == 0x49 && c2 == 0x49 && c3 == 0x2a && c4 == 0x00) - return "image/tiff"; - - if (c1 == 0x4D && c2 == 0x4D && c3 == 0x00 && c4 == 0x2a) - return "image/tiff"; - - if (c1 == 'G' && c2 == 'I' && c3 == 'F' && c4 == '8') - return "image/gif"; - - if (c1 == '#' && c2 == 'd' && c3 == 'e' && c4 == 'f') - return "image/x-bitmap"; - - if (c1 == '!' && c2 == ' ' && c3 == 'X' && c4 == 'P' && c5 == 'M' && c6 == '2') - return "image/x-pixmap"; - - if (c1 == 137 && c2 == 80 && c3 == 78 && c4 == 71 && c5 == 13 && c6 == 10 && c7 == 26 && c8 == 10) - return "image/png"; - - if (c1 == 0xFF && c2 == 0xD8 && c3 == 0xFF) { - if (c4 == 0xE0) - return "image/jpeg"; - - // File format used by digital cameras to store images. - // Exif Format can be read by any application supporting JPEG. Exif Spec can be found at: - // http://www.pima.net/standards/it10/PIMA15740/Exif_2-1.PDF - if ((c4 == 0xE1) && (c7 == 'E' && c8 == 'x' && c9 == 'i' && c10 == 'f' && c11 == 0)) - return "image/jpeg"; - - if (c4 == 0xEE) - return "image/jpg"; - } - - // According to http://www.opendesign.com/files/guestdownloads/OpenDesign_Specification_for_.dwg_files.pdf - // first 6 bytes are of type "AC1018" (for example) and the next 5 bytes are 0x00. - if ((c1 == 0x41 && c2 == 0x43) && (c7 == 0x00 && c8 == 0x00 && c9 == 0x00 && c10 == 0x00 && c11 == 0x00)) - return "application/acad"; - - if (c1 == 0x2E && c2 == 0x73 && c3 == 0x6E && c4 == 0x64) - return "audio/basic"; // .au format, big endian - - if (c1 == 0x64 && c2 == 0x6E && c3 == 0x73 && c4 == 0x2E) - return "audio/basic"; // .au format, little endian - - // I don't know if this is official but evidence suggests that .wav files start with "RIFF" - brown - if (c1 == 'R' && c2 == 'I' && c3 == 'F' && c4 == 'F') - return "audio/x-wav"; - - if (c1 == 'P' && c2 == 'K') { - // its application/zip but this could be a open office thing if name is given - String contentType = guessContentTypeFromName(name); - if (contentType != null) - return contentType; - return "application/zip"; - } - return guessContentTypeFromName(name); - } - - /** - * @param name File name to detect content type by file name. - * @return Content type. - */ - @Nullable public static String guessContentTypeFromName(String name) { - if (name == null) - return null; - - int lastIdx = name.lastIndexOf('.'); - - if (lastIdx != -1) { - String extension = name.substring(lastIdx + 1).toLowerCase(); - - return mimeTypes.get(extension); - } - - return null; - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/util/VisorTaskUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/util/VisorTaskUtils.java index 521d2128340d0..aaeb55387d5c4 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/util/VisorTaskUtils.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/util/VisorTaskUtils.java @@ -17,46 +17,18 @@ package org.apache.ignite.internal.visor.util; -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.FileFilter; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.RandomAccessFile; import java.math.BigDecimal; import java.net.InetAddress; import java.net.UnknownHostException; -import java.nio.ByteBuffer; -import java.nio.channels.FileChannel; -import java.nio.charset.CharacterCodingException; -import java.nio.charset.Charset; -import java.nio.charset.CharsetDecoder; -import java.nio.file.Files; -import java.nio.file.LinkOption; -import java.nio.file.Path; -import java.nio.file.Paths; import java.time.Instant; import java.util.ArrayList; -import java.util.Arrays; import java.util.Collection; -import java.util.Collections; -import java.util.Comparator; -import java.util.HashMap; import java.util.List; -import java.util.Map; -import java.util.SortedMap; -import java.util.concurrent.ConcurrentMap; -import java.util.concurrent.atomic.AtomicBoolean; -import java.util.zip.ZipEntry; -import java.util.zip.ZipOutputStream; import javax.cache.configuration.Factory; -import org.apache.ignite.Ignite; import org.apache.ignite.IgniteLogger; import org.apache.ignite.cache.eviction.AbstractEvictionPolicyFactory; import org.apache.ignite.cluster.ClusterNode; -import org.apache.ignite.events.Event; import org.apache.ignite.internal.IgniteEx; -import org.apache.ignite.internal.managers.discovery.GridDiscoveryManager; import org.apache.ignite.internal.processors.cache.IgniteCacheProxy; import org.apache.ignite.internal.processors.cache.IgniteCacheProxyImpl; import org.apache.ignite.internal.util.IgniteUtils; @@ -64,214 +36,13 @@ import org.apache.ignite.internal.util.typedef.X; import org.apache.ignite.internal.util.typedef.internal.SB; import org.apache.ignite.internal.util.typedef.internal.U; -import org.apache.ignite.internal.visor.event.VisorGridEvent; -import org.apache.ignite.internal.visor.event.VisorGridEventsLost; -import org.apache.ignite.internal.visor.file.VisorFileBlock; -import org.apache.ignite.internal.visor.log.VisorLogFile; -import org.apache.ignite.lang.IgniteClosure; -import org.apache.ignite.lang.IgnitePredicate; -import org.apache.ignite.spi.eventstorage.NoopEventStorageSpi; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import static java.lang.System.getProperty; -import static org.apache.ignite.events.EventType.EVTS_DISCOVERY; -import static org.apache.ignite.events.EventType.EVT_CLASS_DEPLOY_FAILED; -import static org.apache.ignite.events.EventType.EVT_JOB_CANCELLED; -import static org.apache.ignite.events.EventType.EVT_JOB_FAILED; -import static org.apache.ignite.events.EventType.EVT_JOB_FAILED_OVER; -import static org.apache.ignite.events.EventType.EVT_JOB_FINISHED; -import static org.apache.ignite.events.EventType.EVT_JOB_REJECTED; -import static org.apache.ignite.events.EventType.EVT_JOB_STARTED; -import static org.apache.ignite.events.EventType.EVT_JOB_TIMEDOUT; -import static org.apache.ignite.events.EventType.EVT_TASK_DEPLOY_FAILED; -import static org.apache.ignite.events.EventType.EVT_TASK_FAILED; -import static org.apache.ignite.events.EventType.EVT_TASK_FINISHED; -import static org.apache.ignite.events.EventType.EVT_TASK_STARTED; -import static org.apache.ignite.events.EventType.EVT_TASK_TIMEDOUT; - /** * Contains utility methods for Visor tasks and jobs. */ public class VisorTaskUtils { - /** Default substitute for {@code null} names. */ - private static final String DFLT_EMPTY_NAME = ""; - - /** Throttle count for lost events. */ - private static final int EVENTS_LOST_THROTTLE = 10; - - /** Period to grab events. */ - private static final int EVENTS_COLLECT_TIME_WINDOW = 10 * 60 * 1000; - - /** Empty buffer for file block. */ - private static final byte[] EMPTY_FILE_BUF = new byte[0]; - - /** Log files count limit */ - public static final int LOG_FILES_COUNT_LIMIT = 5000; - - /** */ - public static final int NOTHING_TO_REBALANCE = -1; - - /** */ - public static final int REBALANCE_NOT_AVAILABLE = -2; - - /** */ - public static final double MINIMAL_REBALANCE = 0.01; - - /** */ - public static final int REBALANCE_COMPLETE = 1; - - /** */ - private static final int DFLT_BUFFER_SIZE = 4096; - - /** Only task event types that Visor should collect. */ - public static final int[] VISOR_TASK_EVTS = { - EVT_JOB_STARTED, - EVT_JOB_FINISHED, - EVT_JOB_TIMEDOUT, - EVT_JOB_FAILED, - EVT_JOB_FAILED_OVER, - EVT_JOB_REJECTED, - EVT_JOB_CANCELLED, - - EVT_TASK_STARTED, - EVT_TASK_FINISHED, - EVT_TASK_FAILED, - EVT_TASK_TIMEDOUT - }; - - /** Only non task event types that Visor should collect. */ - public static final int[] VISOR_NON_TASK_EVTS = { - EVT_CLASS_DEPLOY_FAILED, - EVT_TASK_DEPLOY_FAILED - }; - - /** Only non task event types that Visor should collect. */ - public static final int[] VISOR_ALL_EVTS = concat(VISOR_TASK_EVTS, VISOR_NON_TASK_EVTS); - - /** Maximum folder depth. I.e. if depth is 4 we look in starting folder and 3 levels of sub-folders. */ - public static final int MAX_FOLDER_DEPTH = 4; - - /** Comparator for log files by last modified date. */ - private static final Comparator LAST_MODIFIED = new Comparator() { - @Override public int compare(VisorLogFile f1, VisorLogFile f2) { - return Long.compare(f2.getLastModified(), f1.getLastModified()); - } - }; - - /** - * @param name Grid-style nullable name. - * @return Name with {@code null} replaced to <default>. - */ - public static String escapeName(@Nullable Object name) { - return name == null ? DFLT_EMPTY_NAME : name.toString(); - } - - /** - * @param name Escaped name. - * @return Name or {@code null} for default name. - */ - public static String unescapeName(String name) { - assert name != null; - - return DFLT_EMPTY_NAME.equals(name) ? null : name; - } - - /** - * Concat arrays in one. - * - * @param arrays Arrays. - * @return Summary array. - */ - public static int[] concat(int[]... arrays) { - assert arrays != null; - assert arrays.length > 1; - - int len = 0; - - for (int[] a : arrays) - len += a.length; - - int[] r = Arrays.copyOf(arrays[0], len); - - for (int i = 1, shift = 0; i < arrays.length; i++) { - shift += arrays[i - 1].length; - System.arraycopy(arrays[i], 0, r, shift, arrays[i].length); - } - - return r; - } - - /** - * Returns compact class host. - * - * @param obj Object to compact. - * @return String. - */ - @Nullable public static Object compactObject(Object obj) { - if (obj == null) - return null; - - if (obj instanceof Enum) - return obj.toString(); - - if (obj instanceof String || obj instanceof Boolean || obj instanceof Number) - return obj; - - if (obj instanceof Collection) { - Collection col = (Collection)obj; - - Object[] res = new Object[col.size()]; - - int i = 0; - - for (Object elm : col) - res[i++] = compactObject(elm); - - return res; - } - - if (obj.getClass().isArray()) { - Class arrType = obj.getClass().getComponentType(); - - if (arrType.isPrimitive()) { - if (obj instanceof boolean[]) - return Arrays.toString((boolean[])obj); - if (obj instanceof byte[]) - return Arrays.toString((byte[])obj); - if (obj instanceof short[]) - return Arrays.toString((short[])obj); - if (obj instanceof int[]) - return Arrays.toString((int[])obj); - if (obj instanceof long[]) - return Arrays.toString((long[])obj); - if (obj instanceof float[]) - return Arrays.toString((float[])obj); - if (obj instanceof double[]) - return Arrays.toString((double[])obj); - } - - Object[] arr = (Object[])obj; - - int iMax = arr.length - 1; - - StringBuilder sb = new StringBuilder("["); - - for (int i = 0; i <= iMax; i++) { - sb.append(compactObject(arr[i])); - - if (i != iMax) - sb.append(", "); - } - - sb.append(']'); - - return sb.toString(); - } - - return U.compact(obj.getClass().getName()); - } - /** * Compact class names. * @@ -318,29 +89,6 @@ public static int[] concat(int[]... arrays) { return res; } - /** - * Joins array elements to string. - * - * @param arr Array. - * @return String. - */ - @Nullable public static String compactArray(Object[] arr) { - if (arr == null || arr.length == 0) - return null; - - String sep = ", "; - - StringBuilder sb = new StringBuilder(); - - for (Object s : arr) - sb.append(s).append(sep); - - if (sb.length() > 0) - sb.setLength(sb.length() - sep.length()); - - return U.compact(sb.toString()); - } - /** * Joins iterable collection elements to string. * @@ -364,376 +112,6 @@ public static int[] concat(int[]... arrays) { return U.compact(sb.toString()); } - /** - * Returns boolean value from system property or provided function. - * - * @param propName System property name. - * @param dflt Function that returns {@code Integer}. - * @return {@code Integer} value - */ - public static Integer intValue(String propName, Integer dflt) { - String sysProp = getProperty(propName); - - return (sysProp != null && !sysProp.isEmpty()) ? Integer.getInteger(sysProp) : dflt; - } - - /** - * Returns boolean value from system property or provided function. - * - * @param propName System property host. - * @param dflt Function that returns {@code Boolean}. - * @return {@code Boolean} value - */ - public static boolean boolValue(String propName, boolean dflt) { - String sysProp = getProperty(propName); - - return (sysProp != null && !sysProp.isEmpty()) ? Boolean.getBoolean(sysProp) : dflt; - } - - /** - * Helper function to get value from map. - * - * @param map Map to take value from. - * @param key Key to search in map. - * @param ifNull Default value if {@code null} was returned by map. - * @param Key type. - * @param Value type. - * @return Value from map or default value if map return {@code null}. - */ - public static V getOrElse(Map map, K key, V ifNull) { - assert map != null; - - V res = map.get(key); - - return res != null ? res : ifNull; - } - - /** - * Checks for explicit events configuration. - * - * @param ignite Grid instance. - * @return {@code true} if all task events explicitly specified in configuration. - */ - public static boolean checkExplicitTaskMonitoring(Ignite ignite) { - int[] evts = ignite.configuration().getIncludeEventTypes(); - - if (F.isEmpty(evts)) - return false; - - for (int evt : VISOR_TASK_EVTS) { - if (!F.contains(evts, evt)) - return false; - } - - return true; - } - - /** Events comparator by event local order. */ - private static final Comparator EVTS_ORDER_COMPARATOR = new Comparator() { - @Override public int compare(Event o1, Event o2) { - return Long.compare(o1.localOrder(), o2.localOrder()); - } - }; - - /** Mapper from grid event to Visor data transfer object. */ - public static final VisorEventMapper EVT_MAPPER = new VisorEventMapper(); - - /** - * Grabs local events and detects if events was lost since last poll. - * - * @param ignite Target grid. - * @param evtOrderKey Unique key to take last order key from node local map. - * @param evtThrottleCntrKey Unique key to take throttle count from node local map. - * @param all If {@code true} then collect all events otherwise collect only non task events. - * @param evtMapper Closure to map grid events to Visor data transfer objects. - * @return Collections of node events - */ - public static Collection collectEvents(Ignite ignite, String evtOrderKey, String evtThrottleCntrKey, - boolean all, IgniteClosure evtMapper) { - int[] evtTypes = all ? VISOR_ALL_EVTS : VISOR_NON_TASK_EVTS; - - // Collect discovery events for Web Console. - if (evtOrderKey.startsWith("CONSOLE_")) - evtTypes = concat(evtTypes, EVTS_DISCOVERY); - - return collectEvents(ignite, evtOrderKey, evtThrottleCntrKey, evtTypes, evtMapper); - } - - /** - * Grabs local events and detects if events was lost since last poll. - * - * @param ignite Target grid. - * @param evtOrderKey Unique key to take last order key from node local map. - * @param evtThrottleCntrKey Unique key to take throttle count from node local map. - * @param evtTypes Event types to collect. - * @param evtMapper Closure to map grid events to Visor data transfer objects. - * @return Collections of node events - */ - public static List collectEvents(Ignite ignite, String evtOrderKey, String evtThrottleCntrKey, - int[] evtTypes, IgniteClosure evtMapper) { - assert ignite != null; - assert evtTypes != null && evtTypes.length > 0; - - ConcurrentMap nl = ignite.cluster().nodeLocalMap(); - - final long lastOrder = getOrElse(nl, evtOrderKey, -1L); - final long throttle = getOrElse(nl, evtThrottleCntrKey, 0L); - - // When we first time arrive onto a node to get its local events, - // we'll grab only last those events that not older than given period to make sure we are - // not grabbing GBs of data accidentally. - final long notOlderThan = System.currentTimeMillis() - EVENTS_COLLECT_TIME_WINDOW; - - // Flag for detecting gaps between events. - final AtomicBoolean lastFound = new AtomicBoolean(lastOrder < 0); - - IgnitePredicate p = new IgnitePredicate() { - /** */ - private static final long serialVersionUID = 0L; - - @Override public boolean apply(Event e) { - // Detects that events were lost. - if (!lastFound.get() && (lastOrder == e.localOrder())) - lastFound.set(true); - - // Retains events by lastOrder, period and type. - return e.localOrder() > lastOrder && e.timestamp() > notOlderThan; - } - }; - - Collection evts = ignite.configuration().getEventStorageSpi() instanceof NoopEventStorageSpi - ? Collections.emptyList() - : ignite.events().localQuery(p, evtTypes); - - // Update latest order in node local, if not empty. - if (!evts.isEmpty()) { - Event maxEvt = Collections.max(evts, EVTS_ORDER_COMPARATOR); - - nl.put(evtOrderKey, maxEvt.localOrder()); - } - - // Update throttle counter. - if (!lastFound.get()) - nl.put(evtThrottleCntrKey, throttle == 0 ? EVENTS_LOST_THROTTLE : throttle - 1); - - boolean lost = !lastFound.get() && throttle == 0; - - List res = new ArrayList<>(evts.size() + (lost ? 1 : 0)); - - if (lost) - res.add(new VisorGridEventsLost(ignite.cluster().localNode().id())); - - for (Event e : evts) { - VisorGridEvent visorEvt = evtMapper.apply(e); - - if (visorEvt != null) - res.add(visorEvt); - } - - return res; - } - - /** - * @param path Path to resolve only relative to IGNITE_HOME. - * @return Resolved path as file, or {@code null} if path cannot be resolved. - * @throws IOException If failed to resolve path. - */ - public static File resolveIgnitePath(String path) throws IOException { - File folder = U.resolveIgnitePath(path); - - if (folder == null) - return null; - - if (!folder.toPath().toRealPath(LinkOption.NOFOLLOW_LINKS).startsWith(Paths.get(U.getIgniteHome()))) - return null; - - return folder; - } - - /** - * @param file File to resolve. - * @return Resolved file if it is a symbolic link or original file. - * @throws IOException If failed to resolve symlink. - */ - public static File resolveSymbolicLink(File file) throws IOException { - Path path = file.toPath(); - - return Files.isSymbolicLink(path) ? Files.readSymbolicLink(path).toFile() : file; - } - - /** - * Finds all files in folder and in it's sub-tree of specified depth. - * - * @param file Starting folder - * @param maxDepth Depth of the tree. If 1 - just look in the folder, no sub-folders. - * @param filter file filter. - * @return List of found files. - * @throws IOException If failed to list files. - */ - public static List fileTree(File file, int maxDepth, @Nullable FileFilter filter) throws IOException { - file = resolveSymbolicLink(file); - - if (file.isDirectory()) { - File[] files = (filter == null) ? file.listFiles() : file.listFiles(filter); - - if (files == null) - return Collections.emptyList(); - - List res = new ArrayList<>(files.length); - - for (File f : files) { - if (f.isFile() && f.length() > 0) - res.add(new VisorLogFile(f)); - else if (maxDepth > 1) - res.addAll(fileTree(f, maxDepth - 1, filter)); - } - - return res; - } - - // Return ArrayList, because it could be sorted in matchedFiles() method. - return new ArrayList<>(F.asList(new VisorLogFile(file))); - } - - /** - * @param file Folder with files to match. - * @param ptrn Pattern to match against file name. - * @return Collection of matched files. - * @throws IOException If failed to filter files. - */ - public static List matchedFiles(File file, final String ptrn) throws IOException { - List files = fileTree(file, MAX_FOLDER_DEPTH, - new FileFilter() { - @Override public boolean accept(File f) { - return !f.isHidden() && (f.isDirectory() || f.isFile() && f.getName().matches(ptrn)); - } - } - ); - - Collections.sort(files, LAST_MODIFIED); - - return files; - } - - /** Text files mime types. */ - private static final String[] TEXT_MIME_TYPE = new String[] {"text/plain", "application/xml", "text/html", "x-sh"}; - - /** - * Check is text file. - * - * @param f file reference. - * @param emptyOk default value if empty file. - * @return Is text file. - */ - public static boolean textFile(File f, boolean emptyOk) { - if (f.length() == 0) - return emptyOk; - - String detected = VisorMimeTypes.getContentType(f); - - for (String mime : TEXT_MIME_TYPE) - if (mime.equals(detected)) - return true; - - return false; - } - - /** - * Decode file charset. - * - * @param f File to process. - * @return File charset. - * @throws IOException in case of error. - */ - public static Charset decode(File f) throws IOException { - SortedMap charsets = Charset.availableCharsets(); - - String[] firstCharsets = {Charset.defaultCharset().name(), "US-ASCII", "UTF-8", "UTF-16BE", "UTF-16LE"}; - - Collection orderedCharsets = U.newLinkedHashSet(charsets.size()); - - for (String c : firstCharsets) - if (charsets.containsKey(c)) - orderedCharsets.add(charsets.get(c)); - - orderedCharsets.addAll(charsets.values()); - - try (RandomAccessFile raf = new RandomAccessFile(f, "r")) { - FileChannel ch = raf.getChannel(); - - ByteBuffer buf = ByteBuffer.allocate(DFLT_BUFFER_SIZE); - - ch.read(buf); - - buf.flip(); - - for (Charset charset : orderedCharsets) { - CharsetDecoder decoder = charset.newDecoder(); - - decoder.reset(); - - try { - decoder.decode(buf); - - return charset; - } - catch (CharacterCodingException ignored) { - } - } - } - - return Charset.defaultCharset(); - } - - /** - * Read block from file. - * - * @param file - File to read. - * @param off - Marker position in file to start read from if {@code -1} read last blockSz bytes. - * @param blockSz - Maximum number of chars to read. - * @param lastModified - File last modification time. - * @return Read file block. - * @throws IOException In case of error. - */ - public static VisorFileBlock readBlock(File file, long off, int blockSz, long lastModified) throws IOException { - RandomAccessFile raf = null; - - try { - long fSz = file.length(); - long fLastModified = file.lastModified(); - - long pos = off >= 0 ? off : Math.max(fSz - blockSz, 0); - - // Try read more that file length. - if (fLastModified == lastModified && fSz != 0 && pos >= fSz) - throw new IOException("Trying to read file block with wrong offset: " + pos + " while file size: " + fSz); - - if (fSz == 0) - return new VisorFileBlock(file.getPath(), pos, fLastModified, 0, false, EMPTY_FILE_BUF); - else { - int toRead = Math.min(blockSz, (int)(fSz - pos)); - - raf = new RandomAccessFile(file, "r"); - raf.seek(pos); - - byte[] buf = new byte[toRead]; - - int cntRead = raf.read(buf, 0, toRead); - - if (cntRead != toRead) - throw new IOException("Count of requested and actually read bytes does not match [cntRead=" + - cntRead + ", toRead=" + toRead + ']'); - - boolean zipped = buf.length > 512; - - return new VisorFileBlock(file.getPath(), pos, fSz, fLastModified, zipped, zipped ? zipBytes(buf) : buf); - } - } - finally { - U.close(raf, null); - } - } - /** * Extract max size from eviction policy if available. * @@ -860,246 +238,6 @@ public static long log(@Nullable IgniteLogger log, String msg, Class clazz, l return end; } - /** - * Log message. - * - * @param log Logger. - * @param msg Message. - */ - public static void log(@Nullable IgniteLogger log, String msg) { - log0(log, System.currentTimeMillis(), " " + msg); - } - - /** - * Checks if address can be reached using one argument InetAddress.isReachable() version or ping command if failed. - * - * @param addr Address to check. - * @param reachTimeout Timeout for the check. - * @return {@code True} if address is reachable. - */ - public static boolean reachableByPing(InetAddress addr, int reachTimeout) { - try { - if (addr.isReachable(reachTimeout)) - return true; - - String cmd = String.format("ping -%s 1 %s", U.isWindows() ? "n" : "c", addr.getHostAddress()); - - Process myProc = Runtime.getRuntime().exec(cmd); - - myProc.waitFor(); - - return myProc.exitValue() == 0; - } - catch (IOException ignore) { - return false; - } - catch (InterruptedException ignored) { - Thread.currentThread().interrupt(); - - return false; - } - } - - /** - * Start local node in terminal. - * - * @param log Logger. - * @param cfgPath Path to node configuration to start with. - * @param nodesToStart Number of nodes to start. - * @param quite If {@code true} then start node in quiet mode. - * @param envVars Optional map with environment variables. - * @return List of started processes. - * @throws IOException If failed to start. - */ - public static List startLocalNode(@Nullable IgniteLogger log, String cfgPath, int nodesToStart, - boolean quite, Map envVars) throws IOException { - String quitePar = quite ? "" : "-v"; - - String cmdFile = new File("bin", U.isWindows() ? "ignite.bat" : "ignite.sh").getPath(); - - File cmdFilePath = U.resolveIgnitePath(cmdFile); - - if (cmdFilePath == null || !cmdFilePath.exists()) - throw new FileNotFoundException(String.format("File not found: %s", cmdFile)); - - File nodesCfgPath = U.resolveIgnitePath(cfgPath); - - if (nodesCfgPath == null || !nodesCfgPath.exists()) - throw new FileNotFoundException(String.format("File not found: %s", cfgPath)); - - String nodeCfg = nodesCfgPath.getCanonicalPath(); - - log(log, String.format("Starting %s local %s with '%s' config", nodesToStart, nodesToStart > 1 ? "nodes" : "node", nodeCfg)); - - List run = new ArrayList<>(); - - try { - String igniteCmd = cmdFilePath.getCanonicalPath(); - - for (int i = 0; i < nodesToStart; i++) { - if (U.isMacOs()) { - Map macEnv = new HashMap<>(System.getenv()); - - if (envVars != null) { - for (Map.Entry ent : envVars.entrySet()) - if (macEnv.containsKey(ent.getKey())) { - String old = macEnv.get(ent.getKey()); - - if (old == null || old.isEmpty()) - macEnv.put(ent.getKey(), ent.getValue()); - else - macEnv.put(ent.getKey(), old + ':' + ent.getValue()); - } - else - macEnv.put(ent.getKey(), ent.getValue()); - } - - StringBuilder envs = new StringBuilder(); - - for (Map.Entry entry : macEnv.entrySet()) { - String val = entry.getValue(); - - if (val.indexOf(';') < 0 && val.indexOf('\'') < 0) - envs.append(String.format("export %s='%s'; ", - entry.getKey(), val.replace('\n', ' ').replace("'", "\'"))); - } - - run.add(openInConsole(envs.toString(), igniteCmd, quitePar, nodeCfg)); - } - else - run.add(openInConsole(null, envVars, igniteCmd, quitePar, nodeCfg)); - } - - return run; - } - catch (Exception e) { - for (Process proc: run) - proc.destroy(); - - throw e; - } - } - - /** - * Run command in separated console. - * - * @param args A string array containing the program and its arguments. - * @return Started process. - * @throws IOException in case of error. - */ - public static Process openInConsole(String... args) throws IOException { - return openInConsole(null, args); - } - - /** - * Run command in separated console. - * - * @param workFolder Work folder for command. - * @param args A string array containing the program and its arguments. - * @return Started process. - * @throws IOException in case of error. - */ - public static Process openInConsole(@Nullable File workFolder, String... args) throws IOException { - return openInConsole(workFolder, null, args); - } - - /** - * Run command in separated console. - * - * @param workFolder Work folder for command. - * @param envVars Optional map with environment variables. - * @param args A string array containing the program and its arguments. - * @return Started process. - * @throws IOException If failed to start process. - */ - public static Process openInConsole(@Nullable File workFolder, Map envVars, String... args) - throws IOException { - String[] commands = args; - - String cmd = F.concat(Arrays.asList(args), " "); - - if (U.isWindows()) - commands = F.asArray("cmd", "/c", String.format("start %s", cmd)); - - if (U.isMacOs()) - commands = F.asArray("osascript", "-e", - String.format("tell application \"Terminal\" to do script \"%s\"", cmd)); - - if (U.isUnix()) - commands = F.asArray("xterm", "-sl", "1024", "-geometry", "200x50", "-e", cmd); - - ProcessBuilder pb = new ProcessBuilder(commands); - - if (workFolder != null) - pb.directory(workFolder); - - if (envVars != null) { - String sep = U.isWindows() ? ";" : ":"; - - Map goalVars = pb.environment(); - - for (Map.Entry var: envVars.entrySet()) { - String envVar = goalVars.get(var.getKey()); - - if (envVar == null || envVar.isEmpty()) - envVar = var.getValue(); - else - envVar += sep + var.getValue(); - - goalVars.put(var.getKey(), envVar); - } - } - - return pb.start(); - } - - /** - * Zips byte array. - * - * @param input Input bytes. - * @return Zipped byte array. - * @throws IOException If failed. - */ - public static byte[] zipBytes(byte[] input) throws IOException { - return zipBytes(input, DFLT_BUFFER_SIZE); - } - - /** - * Zips byte array. - * - * @param input Input bytes. - * @param initBufSize Initial buffer size. - * @return Zipped byte array. - * @throws IOException If failed. - */ - public static byte[] zipBytes(byte[] input, int initBufSize) throws IOException { - ByteArrayOutputStream bos = new ByteArrayOutputStream(initBufSize); - - try (ZipOutputStream zos = new ZipOutputStream(bos)) { - try { - ZipEntry entry = new ZipEntry(""); - - entry.setSize(input.length); - - zos.putNextEntry(entry); - zos.write(input); - } - finally { - zos.closeEntry(); - } - } - - return bos.toByteArray(); - } - - /** - * @param msg Exception message. - * @return {@code true} if node failed to join grid. - */ - public static boolean joinTimedOut(String msg) { - return msg != null && msg.startsWith("Join process timed out."); - } - /** * Special wrapper over address that can be sorted in following order: * IPv4, private IPv4, IPv4 local host, IPv6. @@ -1191,64 +329,6 @@ public String address() { } } - /** - * Sort addresses: IPv4 & real addresses first. - * - * @param addrs Addresses to sort. - * @return Sorted list. - */ - public static Collection sortAddresses(Collection addrs) { - if (F.isEmpty(addrs)) - return Collections.emptyList(); - - int sz = addrs.size(); - - List sorted = new ArrayList<>(sz); - - for (String addr : addrs) - sorted.add(new SortableAddress(addr)); - - Collections.sort(sorted); - - Collection res = new ArrayList<>(sz); - - for (SortableAddress sa : sorted) - res.add(sa.address()); - - return res; - } - - /** - * Split addresses. - * - * @param s String with comma separted addresses. - * @return Collection of addresses. - */ - public static Collection splitAddresses(String s) { - if (F.isEmpty(s)) - return Collections.emptyList(); - - String[] addrs = s.split(","); - - for (int i = 0; i < addrs.length; i++) - addrs[i] = addrs[i].trim(); - - return Arrays.asList(addrs); - } - - /** - * @param ignite Ignite. - * @param cacheName Cache name to check. - * @return {@code true} if cache on local node is not a data cache or near cache disabled. - */ - public static boolean isProxyCache(IgniteEx ignite, String cacheName) { - GridDiscoveryManager discovery = ignite.context().discovery(); - - ClusterNode locNode = ignite.localNode(); - - return !(discovery.cacheAffinityNode(locNode, cacheName) || discovery.cacheNearNode(locNode, cacheName)); - } - /** * Check whether cache restarting in progress. * diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/verify/VisorIdleAnalyzeTask.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/verify/VisorIdleAnalyzeTask.java deleted file mode 100644 index 2d86a428d38bd..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/verify/VisorIdleAnalyzeTask.java +++ /dev/null @@ -1,124 +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.verify; - -import java.util.Collections; -import java.util.List; -import java.util.Map; -import org.apache.ignite.IgniteException; -import org.apache.ignite.compute.ComputeJobContext; -import org.apache.ignite.compute.ComputeTaskFuture; -import org.apache.ignite.internal.processors.cache.verify.CollectConflictPartitionKeysTask; -import org.apache.ignite.internal.processors.cache.verify.PartitionEntryHashRecord; -import org.apache.ignite.internal.processors.cache.verify.PartitionHashRecord; -import org.apache.ignite.internal.processors.cache.verify.RetrieveConflictPartitionValuesTask; -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.VisorOneNodeTask; -import org.apache.ignite.lang.IgniteFuture; -import org.apache.ignite.lang.IgniteInClosure; -import org.apache.ignite.resources.JobContextResource; - -/** - * Task to find diverged keys of conflict partition. - */ -@GridInternal -public class VisorIdleAnalyzeTask extends VisorOneNodeTask { - /** */ - private static final long serialVersionUID = 0L; - - /** {@inheritDoc} */ - @Override protected VisorJob job(VisorIdleAnalyzeTaskArg arg) { - return new VisorIdleVerifyJob(arg, debug); - } - - /** - * - */ - private static class VisorIdleVerifyJob extends VisorJob { - /** */ - private static final long serialVersionUID = 0L; - - /** */ - private ComputeTaskFuture>> conflictKeysFut; - - /** */ - private ComputeTaskFuture>> conflictValsFut; - - /** Auto-inject job context. */ - @JobContextResource - protected transient ComputeJobContext jobCtx; - - /** - * @param arg Argument. - * @param debug Debug. - */ - private VisorIdleVerifyJob(VisorIdleAnalyzeTaskArg arg, boolean debug) { - super(arg, debug); - } - - /** {@inheritDoc} */ - @Override protected VisorIdleAnalyzeTaskResult run(VisorIdleAnalyzeTaskArg arg) throws IgniteException { - if (conflictKeysFut == null) { - conflictKeysFut = ignite.compute() - .executeAsync(CollectConflictPartitionKeysTask.class, arg.getPartitionKey()); - - if (!conflictKeysFut.isDone()) { - jobCtx.holdcc(); - - conflictKeysFut.listen(new IgniteInClosure>>>() { - @Override public void apply(IgniteFuture>> f) { - jobCtx.callcc(); - } - }); - - return null; - } - } - - Map> conflictKeys = conflictKeysFut.get(); - - if (conflictKeys.isEmpty()) - return new VisorIdleAnalyzeTaskResult(Collections.emptyMap()); - - if (conflictValsFut == null) { - conflictValsFut = ignite.compute().executeAsync(RetrieveConflictPartitionValuesTask.class, conflictKeys); - - if (!conflictValsFut.isDone()) { - jobCtx.holdcc(); - - conflictKeysFut.listen(new IgniteInClosure>>>() { - @Override public void apply(IgniteFuture>> f) { - jobCtx.callcc(); - } - }); - - return null; - } - } - - return new VisorIdleAnalyzeTaskResult(conflictValsFut.get()); - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorIdleVerifyJob.class, this); - } - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/verify/VisorIdleAnalyzeTaskArg.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/verify/VisorIdleAnalyzeTaskArg.java deleted file mode 100644 index 884f9610c42a7..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/verify/VisorIdleAnalyzeTaskArg.java +++ /dev/null @@ -1,88 +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.verify; - -import java.io.IOException; -import java.io.ObjectInput; -import java.io.ObjectOutput; -import org.apache.ignite.internal.processors.cache.verify.PartitionKey; -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; - -/** - * Arguments for task {@link VisorIdleAnalyzeTask} - */ -public class VisorIdleAnalyzeTaskArg extends VisorDataTransferObject { - /** */ - private static final long serialVersionUID = 0L; - - /** Partition key. */ - private PartitionKey partKey; - - /** - * Default constructor. - */ - public VisorIdleAnalyzeTaskArg() { - // No-op. - } - - /** - * @param partKey Partition key. - */ - public VisorIdleAnalyzeTaskArg(PartitionKey partKey) { - this.partKey = partKey; - } - - /** - * @param grpId Group id. - * @param partId Partition id. - * @param grpName Group name. - */ - public VisorIdleAnalyzeTaskArg(int grpId, int partId, String grpName) { - this(new PartitionKey(grpId, partId, grpName)); - } - - /** - * @return Partition key. - */ - public PartitionKey getPartitionKey() { - return partKey; - } - - /** {@inheritDoc} */ - @Override protected void writeExternalData(ObjectOutput out) throws IOException { - out.writeInt(partKey.groupId()); - out.writeInt(partKey.partitionId()); - U.writeString(out, partKey.groupName()); - } - - /** {@inheritDoc} */ - @Override protected void readExternalData(byte protoVer, ObjectInput in) throws IOException { - int grpId = in.readInt(); - int partId = in.readInt(); - String grpName = U.readString(in); - - partKey = new PartitionKey(grpId, partId, grpName); - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorIdleAnalyzeTaskArg.class, this); - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/verify/VisorIdleAnalyzeTaskResult.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/verify/VisorIdleAnalyzeTaskResult.java deleted file mode 100644 index e8c129033ef8d..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/verify/VisorIdleAnalyzeTaskResult.java +++ /dev/null @@ -1,76 +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.verify; - -import java.io.IOException; -import java.io.ObjectInput; -import java.io.ObjectOutput; -import java.util.List; -import java.util.Map; -import org.apache.ignite.internal.processors.cache.verify.PartitionEntryHashRecord; -import org.apache.ignite.internal.processors.cache.verify.PartitionHashRecord; -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; - -/** - * Result for task {@link VisorIdleAnalyzeTask} - */ -public class VisorIdleAnalyzeTaskResult extends VisorDataTransferObject { - /** */ - private static final long serialVersionUID = 0L; - - /** Results. */ - private Map> divergedEntries; - - /** - * Default constructor. - */ - public VisorIdleAnalyzeTaskResult() { - // No-op. - } - - /** - * @param divergedEntries Result. - */ - public VisorIdleAnalyzeTaskResult(Map> divergedEntries) { - this.divergedEntries = divergedEntries; - } - - /** - * @return Results. - */ - public Map> getDivergedEntries() { - return divergedEntries; - } - - /** {@inheritDoc} */ - @Override protected void writeExternalData(ObjectOutput out) throws IOException { - U.writeMap(out, divergedEntries); - } - - /** {@inheritDoc} */ - @Override protected void readExternalData(byte protoVer, ObjectInput in) throws IOException, ClassNotFoundException { - divergedEntries = U.readMap(in); - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorIdleAnalyzeTaskResult.class, this); - } -}