-
Notifications
You must be signed in to change notification settings - Fork 1.9k
/
VisorQueryCleanupTask.java
102 lines (85 loc) · 3.42 KB
/
VisorQueryCleanupTask.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
/*
* 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.cluster.*;
import org.apache.ignite.compute.*;
import org.apache.ignite.internal.processors.task.*;
import org.apache.ignite.internal.util.typedef.internal.*;
import org.apache.ignite.internal.visor.*;
import org.jetbrains.annotations.*;
import java.util.*;
import java.util.concurrent.*;
import static org.apache.ignite.internal.visor.util.VisorTaskUtils.*;
/**
* Task for cleanup not needed SCAN or SQL queries result futures from node local.
*/
@GridInternal
public class VisorQueryCleanupTask extends VisorMultiNodeTask<Map<UUID, Collection<String>>, Void, Void> {
/** */
private static final long serialVersionUID = 0L;
/** {@inheritDoc} */
@Override protected VisorJob<Map<UUID, Collection<String>>, Void> job(Map<UUID, Collection<String>> arg) {
return null;
}
/** {@inheritDoc} */
@Override protected Map<? extends ComputeJob, ClusterNode> map0(List<ClusterNode> subgrid,
@Nullable VisorTaskArgument<Map<UUID, Collection<String>>> arg) {
Set<UUID> nodeIds = taskArg.keySet();
Map<ComputeJob, ClusterNode> map = U.newHashMap(nodeIds.size());
try {
for (ClusterNode node : subgrid)
if (nodeIds.contains(node.id()))
map.put(new VisorQueryCleanupJob(taskArg.get(node.id()), debug), node);
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<Collection<String>, Void> {
/** */
private static final long serialVersionUID = 0L;
/**
* Create job with specified argument.
*
* @param arg Job argument.
* @param debug Debug flag.
*/
protected VisorQueryCleanupJob(Collection<String> arg, boolean debug) {
super(arg, debug);
}
/** {@inheritDoc} */
@Override protected Void run(Collection<String> qryIds) {
ConcurrentMap<String, VisorQueryTask.VisorFutureResultSetHolder> locMap = ignite.cluster().nodeLocalMap();
for (String qryId : qryIds)
locMap.remove(qryId);
return null;
}
/** {@inheritDoc} */
@Override public String toString() {
return S.toString(VisorQueryCleanupJob.class, this);
}
}
}