-
Notifications
You must be signed in to change notification settings - Fork 228
/
InfinispanHotRodExecutionFactory.java
190 lines (159 loc) · 5.76 KB
/
InfinispanHotRodExecutionFactory.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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
/*
* JBoss, Home of Professional Open Source.
* See the COPYRIGHT.txt file distributed with this work for information
* regarding copyright ownership. Some portions may be licensed
* to Red Hat, Inc. under one or more contributor license agreements.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*/
package org.teiid.translator.infinispan.hotrod;
import java.util.List;
import org.teiid.language.Argument;
import org.teiid.language.Command;
import org.teiid.metadata.RuntimeMetadata;
import org.teiid.translator.ExecutionContext;
import org.teiid.translator.MetadataProcessor;
import org.teiid.translator.ProcedureExecution;
import org.teiid.translator.Translator;
import org.teiid.translator.TranslatorException;
import org.teiid.translator.TranslatorProperty;
import org.teiid.translator.infinispan.hotrod.metadata.AnnotationMetadataProcessor;
import org.teiid.translator.infinispan.hotrod.metadata.ProtobufMetadataProcessor;
import org.teiid.translator.object.ObjectConnection;
import org.teiid.translator.object.ObjectExecutionFactory;
import org.teiid.translator.object.Version;
/**
* InfinispanExecutionFactory is the translator that will be use to translate a remote Infinispan cache and issue queries
* using hotrod client to query the cache.
*
* @author vhalbert
*
* @since 8.7
*
*/
@Translator(name = "ispn-hotrod", description = "The Infinispan Translator Using Hotrod Client to query cache")
public class InfinispanHotRodExecutionFactory extends ObjectExecutionFactory {
public static final Version SIX_6 = Version.getVersion("6.6"); //$NON-NLS-1$
// max available without having to try to override
// BooleanQuery.setMaxClauseCount(), and
// infinispan doesn't currently support that option.
// https://issues.jboss.org/browse/ISPN-6728
public static final int MAX_SET_SIZE = 1024;
private boolean supportsCompareCriteriaOrdered = false;
public InfinispanHotRodExecutionFactory() {
super();
setSourceRequiredForMetadata(true);
setMaxInCriteriaSize(MAX_SET_SIZE);
setMaxDependentInPredicates(5);
setSupportsOrderBy(true);
setSupportsSelectDistinct(false);
setSupportsInnerJoins(true);
setSupportsFullOuterJoins(false);
setSupportsOuterJoins(true);
setSupportedJoinCriteria(SupportedJoinCriteria.KEY);
}
@Override
public int getMaxFromGroups() {
return 2;
}
/**
* {@inheritDoc}
*
* @see org.teiid.translator.object.ObjectExecutionFactory#createDirectExecution(java.util.List, org.teiid.language.Command, org.teiid.translator.ExecutionContext, org.teiid.metadata.RuntimeMetadata, org.teiid.translator.object.ObjectConnection)
*/
@Override
public ProcedureExecution createDirectExecution(List<Argument> arguments,
Command command, ExecutionContext executionContext,
RuntimeMetadata metadata, ObjectConnection connection) {
return super.createDirectExecution(arguments, command, executionContext,
metadata, connection);
}
@Override
public boolean supportsAliasedTable() {
return true;
}
@Override
public boolean supportsInCriteria() {
return Boolean.TRUE.booleanValue();
}
/**
* Discusses issue with trying to support IS NULL and IS NOT NULL;
* @return boolean
*/
// "https://issues.jboss.org/browse/TEIID-3573"
@Override
public boolean supportsIsNullCriteria() {
return Boolean.FALSE.booleanValue();
}
@Override
public boolean supportsOrCriteria() {
return Boolean.TRUE.booleanValue();
}
@Override
public boolean supportsCompareCriteriaEquals() {
return Boolean.TRUE.booleanValue();
}
@TranslatorProperty(display="CompareCriteriaOrdered", description="If true, translator can support comparison criteria with the operator '=>' or '<=' ",advanced=true)
@Override
public boolean supportsCompareCriteriaOrdered() {
return supportsCompareCriteriaOrdered;
}
public boolean setSupportsCompareCriteriaOrdered(boolean supports) {
return supportsCompareCriteriaOrdered = supports;
}
@Override
public boolean supportsLikeCriteria() {
return Boolean.TRUE.booleanValue();
}
@Override
public boolean supportsLikeCriteriaEscapeCharacter() {
return Boolean.TRUE.booleanValue();
}
/**
* Discusses issue with trying to support NOT;
*/
// https://issues.jboss.org/browse/TEIID-3573
@Override
public boolean supportsNotCriteria() {
return Boolean.FALSE.booleanValue();
}
@Override
public MetadataProcessor<ObjectConnection> getMetadataProcessor(){
if (this.supportsSearchabilityUsingAnnotations()) {
return new AnnotationMetadataProcessor(true);
}
return new ProtobufMetadataProcessor();
}
/**
* {@inheritDoc}
*
* @see org.teiid.translator.ExecutionFactory#initCapabilities(java.lang.Object)
*/
@Override
public void initCapabilities(ObjectConnection connection)
throws TranslatorException {
super.initCapabilities(connection);
if (connection == null) {
return;
}
Version version = connection.getVersion();
// with JDG 6.6 supportCompareCriteria no longer needs to be disabled
// @see @link https://issues.jboss.org/browse/TEIID-4333
if (version != null && version.compareTo(SIX_6) >= 0) {
this.supportsCompareCriteriaOrdered = true;
}
}
}