Skip to content

Commit

Permalink
interop .Net: Merge from sp31 (without .Net component).
Browse files Browse the repository at this point in the history
  • Loading branch information
vozerov-gridgain committed Jan 16, 2015
1 parent 725d79f commit c0c28ab
Show file tree
Hide file tree
Showing 17 changed files with 318 additions and 88 deletions.
Expand Up @@ -112,7 +112,7 @@ public interface PortableRawReader {
* @return Object. * @return Object.
* @throws PortableException In case of error. * @throws PortableException In case of error.
*/ */
@Nullable public Object readObject() throws PortableException; @Nullable public <T> T readObject() throws PortableException;


/** /**
* @return Byte array. * @return Byte array.
Expand Down
Expand Up @@ -41,7 +41,8 @@ public GridDotNetConfiguration() {


/** /**
* Copy constructor. * Copy constructor.
* @param cfg configuration to copy. *
* @param cfg Configuration to copy.
*/ */
public GridDotNetConfiguration(GridDotNetConfiguration cfg) { public GridDotNetConfiguration(GridDotNetConfiguration cfg) {
if (cfg.getPortableConfiguration() != null) if (cfg.getPortableConfiguration() != null)
Expand Down Expand Up @@ -80,6 +81,15 @@ public void setAssemblies(List<String> assemblies) {
this.assemblies = assemblies; this.assemblies = assemblies;
} }


/**
* Copy configuration.
*
* @return Copied configuration.
*/
public GridDotNetConfiguration copy() {
return new GridDotNetConfiguration(this);
}

/** {@inheritDoc} */ /** {@inheritDoc} */
@Override public void writePortable(PortableWriter writer) throws PortableException { @Override public void writePortable(PortableWriter writer) throws PortableException {
PortableRawWriter rawWriter = writer.rawWriter(); PortableRawWriter rawWriter = writer.rawWriter();
Expand All @@ -92,7 +102,7 @@ public void setAssemblies(List<String> assemblies) {
@Override public void readPortable(PortableReader reader) throws PortableException { @Override public void readPortable(PortableReader reader) throws PortableException {
PortableRawReader rawReader = reader.rawReader(); PortableRawReader rawReader = reader.rawReader();


portableCfg = (GridDotNetPortableConfiguration)rawReader.readObject(); portableCfg = rawReader.readObject();
assemblies = (List<String>)rawReader.<String>readCollection(); assemblies = (List<String>)rawReader.<String>readCollection();
} }


Expand Down
Expand Up @@ -45,7 +45,7 @@ public class GridDotNetPortableConfiguration implements PortableMarshalAware {
private boolean dfltMetadataEnabled = true; private boolean dfltMetadataEnabled = true;


/** Whether to cache deserialized value in IGridPortableObject */ /** Whether to cache deserialized value in IGridPortableObject */
private boolean keepDeserialized = true; private boolean dfltKeepDeserialized = true;


/** /**
* Default constructor. * Default constructor.
Expand Down Expand Up @@ -73,7 +73,7 @@ public GridDotNetPortableConfiguration(GridDotNetPortableConfiguration cfg) {
dfltIdMapper = cfg.getDefaultIdMapper(); dfltIdMapper = cfg.getDefaultIdMapper();
dfltSerializer = cfg.getDefaultSerializer(); dfltSerializer = cfg.getDefaultSerializer();
dfltMetadataEnabled = cfg.getDefaultMetadataEnabled(); dfltMetadataEnabled = cfg.getDefaultMetadataEnabled();
keepDeserialized = cfg.getKeepDeserialized(); dfltKeepDeserialized = cfg.getDefaultKeepDeserialized();
} }


/** /**
Expand Down Expand Up @@ -163,53 +163,41 @@ public void setDefaultMetadataEnabled(boolean dfltMetadataEnabled) {
/** /**
* @return Flag indicates whether to cache deserialized value in IGridPortableObject. * @return Flag indicates whether to cache deserialized value in IGridPortableObject.
*/ */
public boolean getKeepDeserialized() { public boolean getDefaultKeepDeserialized() {
return keepDeserialized; return dfltKeepDeserialized;
} }


/** /**
* @param keepDeserialized Keep deserialized flag. * @param keepDeserialized Keep deserialized flag.
*/ */
public void setKeepDeserialized(boolean keepDeserialized) { public void setDefaultKeepDeserialized(boolean keepDeserialized) {
this.keepDeserialized = keepDeserialized; this.dfltKeepDeserialized = keepDeserialized;
} }


/** {@inheritDoc} */ /** {@inheritDoc} */
@Override public void writePortable(PortableWriter writer) throws PortableException { @Override public void writePortable(PortableWriter writer) throws PortableException {
PortableRawWriter rawWriter = writer.rawWriter(); PortableRawWriter rawWriter = writer.rawWriter();


rawWriter.writeCollection(typesCfg); rawWriter.writeCollection(typesCfg);

rawWriter.writeCollection(types); rawWriter.writeCollection(types);

rawWriter.writeString(dfltNameMapper); rawWriter.writeString(dfltNameMapper);

rawWriter.writeString(dfltIdMapper); rawWriter.writeString(dfltIdMapper);

rawWriter.writeString(dfltSerializer); rawWriter.writeString(dfltSerializer);

rawWriter.writeBoolean(dfltMetadataEnabled); rawWriter.writeBoolean(dfltMetadataEnabled);

rawWriter.writeBoolean(dfltKeepDeserialized);
rawWriter.writeBoolean(keepDeserialized);
} }


/** {@inheritDoc} */ /** {@inheritDoc} */
@Override public void readPortable(PortableReader reader) throws PortableException { @Override public void readPortable(PortableReader reader) throws PortableException {
PortableRawReader rawReader = reader.rawReader(); PortableRawReader rawReader = reader.rawReader();


typesCfg = rawReader.readCollection(); typesCfg = rawReader.readCollection();

types = rawReader.readCollection(); types = rawReader.readCollection();

dfltNameMapper = rawReader.readString(); dfltNameMapper = rawReader.readString();

dfltIdMapper = rawReader.readString(); dfltIdMapper = rawReader.readString();

dfltSerializer = rawReader.readString(); dfltSerializer = rawReader.readString();

dfltMetadataEnabled = rawReader.readBoolean(); dfltMetadataEnabled = rawReader.readBoolean();

dfltKeepDeserialized = rawReader.readBoolean();
keepDeserialized = rawReader.readBoolean();
} }


/** {@inheritDoc} */ /** {@inheritDoc} */
Expand Down
Expand Up @@ -68,6 +68,7 @@ public GridDotNetPortableTypeConfiguration(GridDotNetPortableTypeConfiguration c
serializer = cfg.getSerializer(); serializer = cfg.getSerializer();
affinityKeyFieldName = cfg.getAffinityKeyFieldName(); affinityKeyFieldName = cfg.getAffinityKeyFieldName();
metadataEnabled = cfg.getMetadataEnabled(); metadataEnabled = cfg.getMetadataEnabled();
keepDeserialized = cfg.isKeepDeserialized();
} }


/** /**
Expand Down Expand Up @@ -187,19 +188,12 @@ public void setKeepDeserialized(@Nullable Boolean keepDeserialized) {
PortableRawWriter rawWriter = writer.rawWriter(); PortableRawWriter rawWriter = writer.rawWriter();


rawWriter.writeString(assemblyName); rawWriter.writeString(assemblyName);

rawWriter.writeString(typeName); rawWriter.writeString(typeName);

rawWriter.writeString(nameMapper); rawWriter.writeString(nameMapper);

rawWriter.writeString(idMapper); rawWriter.writeString(idMapper);

rawWriter.writeString(serializer); rawWriter.writeString(serializer);

rawWriter.writeString(affinityKeyFieldName); rawWriter.writeString(affinityKeyFieldName);

rawWriter.writeObject(metadataEnabled); rawWriter.writeObject(metadataEnabled);

rawWriter.writeObject(keepDeserialized); rawWriter.writeObject(keepDeserialized);
} }


Expand All @@ -208,19 +202,12 @@ public void setKeepDeserialized(@Nullable Boolean keepDeserialized) {
PortableRawReader rawReader = reader.rawReader(); PortableRawReader rawReader = reader.rawReader();


assemblyName = rawReader.readString(); assemblyName = rawReader.readString();

typeName = rawReader.readString(); typeName = rawReader.readString();

nameMapper = rawReader.readString(); nameMapper = rawReader.readString();

idMapper = rawReader.readString(); idMapper = rawReader.readString();

serializer = rawReader.readString(); serializer = rawReader.readString();

affinityKeyFieldName = rawReader.readString(); affinityKeyFieldName = rawReader.readString();

metadataEnabled = (Boolean)rawReader.readObject(); metadataEnabled = (Boolean)rawReader.readObject();

keepDeserialized = (Boolean)rawReader.readObject(); keepDeserialized = (Boolean)rawReader.readObject();
} }


Expand Down
76 changes: 56 additions & 20 deletions modules/core/src/main/java/org/gridgain/grid/kernal/GridGainEx.java
Expand Up @@ -525,15 +525,15 @@ public static Ignite start(@Nullable String springCfgPath, @Nullable String grid
* *
* @param springCfgPath Spring config path. * @param springCfgPath Spring config path.
* @param gridName Grid name. * @param gridName Grid name.
* @param envPtr Environment pointer. * @param cfgClo Configuration closure.
* @return Started Grid. * @return Started Grid.
* @throws IgniteCheckedException If failed. * @throws IgniteCheckedException If failed.
*/ */
public static Ignite startInterop(@Nullable String springCfgPath, @Nullable String gridName, long envPtr) public static Ignite startInterop(@Nullable String springCfgPath, @Nullable String gridName,
throws IgniteCheckedException { IgniteClosure<IgniteConfiguration, IgniteConfiguration> cfgClo) throws IgniteCheckedException {
GridInteropProcessorAdapter.ENV_PTR.set(envPtr); URL url = resolveSpringUrl(springCfgPath);


return start(springCfgPath, gridName); return start(url, gridName, null, cfgClo);
} }


/** /**
Expand Down Expand Up @@ -654,21 +654,7 @@ public static IgniteBiTuple<IgniteConfiguration, GridSpringResourceContext> load
*/ */
public static Ignite start(String springCfgPath, @Nullable String gridName, public static Ignite start(String springCfgPath, @Nullable String gridName,
@Nullable GridSpringResourceContext springCtx) throws IgniteCheckedException { @Nullable GridSpringResourceContext springCtx) throws IgniteCheckedException {
A.notNull(springCfgPath, "springCfgPath"); URL url = resolveSpringUrl(springCfgPath);

URL url;

try {
url = new URL(springCfgPath);
}
catch (MalformedURLException e) {
url = U.resolveGridGainUrl(springCfgPath);

if (url == null)
throw new IgniteCheckedException("Spring XML configuration path is invalid: " + springCfgPath +
". Note that this path should be either absolute or a relative local file system path, " +
"relative to META-INF in classpath or valid URL to GRIDGAIN_HOME.", e);
}


return start(url, gridName, springCtx); return start(url, gridName, springCtx);
} }
Expand Down Expand Up @@ -716,6 +702,23 @@ public static Ignite start(URL springCfgUrl) throws IgniteCheckedException {
*/ */
public static Ignite start(URL springCfgUrl, @Nullable String gridName, public static Ignite start(URL springCfgUrl, @Nullable String gridName,
@Nullable GridSpringResourceContext springCtx) throws IgniteCheckedException { @Nullable GridSpringResourceContext springCtx) throws IgniteCheckedException {
return start(springCfgUrl, gridName, springCtx, null);
}

/**
* Internal Spring-based start routine.
*
* @param springCfgUrl Spring XML configuration file URL. This cannot be {@code null}.
* @param gridName Grid name that will override default.
* @param springCtx Optional Spring application context.
* @param cfgClo Optional closure to change configuration before it is used to start the grid.
* @return Started grid.
* @throws IgniteCheckedException If failed.
*/
private static Ignite start(URL springCfgUrl, @Nullable String gridName,
@Nullable GridSpringResourceContext springCtx,
@Nullable IgniteClosure<IgniteConfiguration, IgniteConfiguration> cfgClo)
throws IgniteCheckedException {
A.notNull(springCfgUrl, "springCfgUrl"); A.notNull(springCfgUrl, "springCfgUrl");


boolean isLog4jUsed = U.gridClassLoader().getResource("org/apache/log4j/Appender.class") != null; boolean isLog4jUsed = U.gridClassLoader().getResource("org/apache/log4j/Appender.class") != null;
Expand Down Expand Up @@ -751,6 +754,12 @@ public static Ignite start(URL springCfgUrl, @Nullable String gridName,
if (cfg.getGridName() == null && !F.isEmpty(gridName)) if (cfg.getGridName() == null && !F.isEmpty(gridName))
cfg.setGridName(gridName); cfg.setGridName(gridName);


if (cfgClo != null) {
cfg = cfgClo.apply(cfg);

assert cfg != null;
}

// Use either user defined context or our one. // Use either user defined context or our one.
GridNamedInstance grid = start0( GridNamedInstance grid = start0(
new GridStartContext(cfg, springCfgUrl, springCtx == null ? cfgMap.get2() : springCtx)); new GridStartContext(cfg, springCfgUrl, springCtx == null ? cfgMap.get2() : springCtx));
Expand Down Expand Up @@ -780,6 +789,33 @@ public static Ignite start(URL springCfgUrl, @Nullable String gridName,
return res != null ? res.grid() : null; return res != null ? res.grid() : null;
} }


/**
* Resolve Spring configuration URL.
*
* @param springCfgPath Spring XML configuration file path or URL. This cannot be {@code null}.
* @return URL.
* @throws IgniteCheckedException If failed.
*/
private static URL resolveSpringUrl(String springCfgPath) throws IgniteCheckedException {
A.notNull(springCfgPath, "springCfgPath");

URL url;

try {
url = new URL(springCfgPath);
}
catch (MalformedURLException e) {
url = U.resolveGridGainUrl(springCfgPath);

if (url == null)
throw new IgniteCheckedException("Spring XML configuration path is invalid: " + springCfgPath +
". Note that this path should be either absolute or a relative local file system path, " +
"relative to META-INF in classpath or valid URL to GRIDGAIN_HOME.", e);
}

return url;
}

/** /**
* Starts grid with given configuration. * Starts grid with given configuration.
* *
Expand Down
Expand Up @@ -22,7 +22,7 @@
*/ */
public final class GridNodeAttributes { public final class GridNodeAttributes {
/** Prefix for internally reserved attribute names. */ /** Prefix for internally reserved attribute names. */
static final String ATTR_PREFIX = "org.gridgain"; public static final String ATTR_PREFIX = "org.gridgain";


/** Node compound version. */ /** Node compound version. */
public static final String ATTR_BUILD_VER = ATTR_PREFIX + ".build.ver"; public static final String ATTR_BUILD_VER = ATTR_PREFIX + ".build.ver";
Expand Down Expand Up @@ -136,9 +136,6 @@ public final class GridNodeAttributes {
/** Cache interceptors. */ /** Cache interceptors. */
public static final String ATTR_CACHE_INTERCEPTORS = ATTR_PREFIX + ".cache.interceptors"; public static final String ATTR_CACHE_INTERCEPTORS = ATTR_PREFIX + ".cache.interceptors";


/** Native platform. */
public static final String ATTR_INTEROP_PLATFORM = ATTR_PREFIX + ".interop.platform";

/** /**
* Enforces singleton. * Enforces singleton.
*/ */
Expand Down
Expand Up @@ -399,16 +399,25 @@ public boolean isDht() {


/** {@inheritDoc} */ /** {@inheritDoc} */
@Override public <K1, V1> GridCacheProjection<K1, V1> keepPortable() { @Override public <K1, V1> GridCacheProjection<K1, V1> keepPortable() {
GridCacheProjectionImpl<K1, V1> prj = new GridCacheProjectionImpl<>( GridCacheProjectionImpl<K1, V1> prj = keepPortable0();

return new GridCacheProxyImpl<>((GridCacheContext<K1, V1>)ctx, prj, prj);
}

/**
* Internal routine to get "keep-portable" projection.
*
* @return Projection with "keep-portable" flag.
*/
public <K1, V1> GridCacheProjectionImpl<K1, V1> keepPortable0() {
return new GridCacheProjectionImpl<>(
(GridCacheProjection<K1, V1>)this, (GridCacheProjection<K1, V1>)this,
(GridCacheContext<K1, V1>)ctx, (GridCacheContext<K1, V1>)ctx,
null, null,
null, null,
null, null,
null, null,
ctx.portableEnabled()); ctx.portableEnabled());

return new GridCacheProxyImpl<>((GridCacheContext<K1, V1>)ctx, prj, prj);
} }


/** {@inheritDoc} */ /** {@inheritDoc} */
Expand Down
Expand Up @@ -1063,7 +1063,7 @@ public GridCacheFlag[] forcedFlags() {
* *
* @param prj Flags to set. * @param prj Flags to set.
*/ */
void projectionPerCall(@Nullable GridCacheProjectionImpl<K, V> prj) { public void projectionPerCall(@Nullable GridCacheProjectionImpl<K, V> prj) {
if (nearContext()) if (nearContext())
dht().near().context().prjPerCall.set(prj); dht().near().context().prjPerCall.set(prj);
else else
Expand Down
Expand Up @@ -406,7 +406,7 @@ protected void reset() {


/** {@inheritDoc} */ /** {@inheritDoc} */
@Nullable @Override public V get() throws IgniteCheckedException { @Nullable @Override public V get() throws IgniteCheckedException {
return proxy.get(key, isNearEnabled(ctx) ? null : cached, true); return proxy.get(key, isNearEnabled(ctx) ? null : cached, !ctx.keepPortable());
} }


/** {@inheritDoc} */ /** {@inheritDoc} */
Expand Down
Expand Up @@ -20,7 +20,6 @@
import org.apache.ignite.*; import org.apache.ignite.*;
import org.apache.ignite.cluster.*; import org.apache.ignite.cluster.*;
import org.apache.ignite.lang.*; import org.apache.ignite.lang.*;
import org.gridgain.grid.*;
import org.gridgain.grid.cache.*; import org.gridgain.grid.cache.*;
import org.gridgain.grid.cache.query.*; import org.gridgain.grid.cache.query.*;
import org.gridgain.grid.cache.query.GridCacheContinuousQueryEntry; import org.gridgain.grid.cache.query.GridCacheContinuousQueryEntry;
Expand Down Expand Up @@ -56,6 +55,9 @@ public class GridCacheContinuousQueryAdapter<K, V> implements GridCacheContinuou
/** Projection predicate */ /** Projection predicate */
private final IgnitePredicate<GridCacheEntry<K, V>> prjPred; private final IgnitePredicate<GridCacheEntry<K, V>> prjPred;


/** Keep portable flag. */
private final boolean keepPortable;

/** Logger. */ /** Logger. */
private final IgniteLogger log; private final IgniteLogger log;


Expand Down Expand Up @@ -98,6 +100,8 @@ public class GridCacheContinuousQueryAdapter<K, V> implements GridCacheContinuou
this.topic = topic; this.topic = topic;
this.prjPred = prjPred; this.prjPred = prjPred;


keepPortable = ctx.keepPortable();

log = ctx.logger(getClass()); log = ctx.logger(getClass());
} }


Expand Down Expand Up @@ -279,9 +283,12 @@ public void execute(@Nullable ClusterGroup prj, boolean internal) throws IgniteC


guard.block(); guard.block();


GridContinuousHandler hnd = ctx.kernalContext().security().enabled() ? GridContinuousHandler hnd = ctx.kernalContext().security().enabled() ? keepPortable ?
new GridCacheContinuousQueryHandlerV2<>(ctx.name(), topic, locCb, rmtFilter, prjPred, internal, new GridCacheContinuousQueryHandlerV4<>(ctx.name(), topic, locCb, rmtFilter, prjPred, internal,
ctx.kernalContext().job().currentTaskNameHash()) : ctx.kernalContext().job().currentTaskNameHash()) :
new GridCacheContinuousQueryHandlerV2<>(ctx.name(), topic, locCb, rmtFilter, prjPred, internal,
ctx.kernalContext().job().currentTaskNameHash()) : keepPortable ?
new GridCacheContinuousQueryHandlerV3<>(ctx.name(), topic, locCb, rmtFilter, prjPred, internal) :
new GridCacheContinuousQueryHandler<>(ctx.name(), topic, locCb, rmtFilter, prjPred, internal); new GridCacheContinuousQueryHandler<>(ctx.name(), topic, locCb, rmtFilter, prjPred, internal);


routineId = ctx.kernalContext().continuous().startRoutine(hnd, bufSize, timeInterval, autoUnsubscribe, routineId = ctx.kernalContext().continuous().startRoutine(hnd, bufSize, timeInterval, autoUnsubscribe,
Expand Down

0 comments on commit c0c28ab

Please sign in to comment.