Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
sboikov committed Feb 26, 2015
1 parent 8a92246 commit 7d31dde
Show file tree
Hide file tree
Showing 8 changed files with 81 additions and 48 deletions.
@@ -0,0 +1,29 @@
/*
* 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.cache;

import java.lang.annotation.*;

/**
*
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
public @interface IgniteImmutable {
// No-op.
}
Expand Up @@ -217,6 +217,9 @@ public class CacheConfiguration<K, V> extends MutableConfiguration<K, V> {
/** Cache distribution mode. */ /** Cache distribution mode. */
private CacheDistributionMode distro = DFLT_DISTRIBUTION_MODE; private CacheDistributionMode distro = DFLT_DISTRIBUTION_MODE;


/** Default value for 'copyOnGet' flag. */
public static final boolean DFLT_COPY_ON_GET = true;

/** Write synchronization mode. */ /** Write synchronization mode. */
private CacheWriteSynchronizationMode writeSync; private CacheWriteSynchronizationMode writeSync;


Expand Down Expand Up @@ -319,6 +322,9 @@ public class CacheConfiguration<K, V> extends MutableConfiguration<K, V> {
/** Collection of type metadata. */ /** Collection of type metadata. */
private Collection<CacheTypeMetadata> typeMeta; private Collection<CacheTypeMetadata> typeMeta;


/** */
private boolean cpOnGet = DFLT_COPY_ON_GET;

/** Empty constructor (all values are initialized to their defaults). */ /** Empty constructor (all values are initialized to their defaults). */
public CacheConfiguration() { public CacheConfiguration() {
/* No-op. */ /* No-op. */
Expand Down Expand Up @@ -1620,6 +1626,20 @@ public void setReadFromBackup(boolean readFromBackup) {
this.readFromBackup = readFromBackup; this.readFromBackup = readFromBackup;
} }


/**
* @return Copy on get flag.
*/
public boolean isCopyOnGet() {
return cpOnGet;
}

/**
* @param cpOnGet Copy on get flag.
*/
public void setCopyOnGet(boolean cpOnGet) {
this.cpOnGet = cpOnGet;
}

/** {@inheritDoc} */ /** {@inheritDoc} */
@Override public String toString() { @Override public String toString() {
return S.toString(CacheConfiguration.class, this); return S.toString(CacheConfiguration.class, this);
Expand Down
Expand Up @@ -1806,6 +1806,9 @@ public <K1, V1> void addResult(Map<K1, V1> map,
Object key0 = key.value(this); Object key0 = key.value(this);
Object val0 = skipVals ? Boolean.TRUE : val.value(this); Object val0 = skipVals ? Boolean.TRUE : val.value(this);


assert key0 != null;
assert val0 != null;

if (portableEnabled() && deserializePortable) { if (portableEnabled() && deserializePortable) {
key0 = unwrapPortableIfNeeded(key0, false); key0 = unwrapPortableIfNeeded(key0, false);


Expand Down
Expand Up @@ -338,7 +338,7 @@ protected GridCacheValueBytes valueBytesUnlocked() {


/** {@inheritDoc} */ /** {@inheritDoc} */
@Override public boolean isInternal() { @Override public boolean isInternal() {
return key instanceof GridCacheInternal; return key.internal();
} }


/** {@inheritDoc} */ /** {@inheritDoc} */
Expand Down
Expand Up @@ -44,13 +44,9 @@ public class GridDhtForceKeysRequest extends GridCacheMessage implements GridCac
/** Mini-future ID. */ /** Mini-future ID. */
private IgniteUuid miniId; private IgniteUuid miniId;


/** Serialized keys. */
@GridDirectCollection(byte[].class)
private Collection<byte[]> keyBytes;

/** Keys to request. */ /** Keys to request. */
@GridToStringInclude @GridToStringInclude
@GridDirectTransient @GridDirectCollection(KeyCacheObject.class)
private Collection<KeyCacheObject> keys; private Collection<KeyCacheObject> keys;


/** Topology version for which keys are requested. */ /** Topology version for which keys are requested. */
Expand Down Expand Up @@ -116,13 +112,6 @@ public IgniteUuid miniId() {
return miniId; return miniId;
} }


/**
* @return Collection of serialized keys.
*/
public Collection<byte[]> keyBytes() {
return keyBytes;
}

/** /**
* @return Keys. * @return Keys.
*/ */
Expand All @@ -142,23 +131,21 @@ public Collection<KeyCacheObject> keys() {
@Override public void prepareMarshal(GridCacheSharedContext ctx) throws IgniteCheckedException { @Override public void prepareMarshal(GridCacheSharedContext ctx) throws IgniteCheckedException {
super.prepareMarshal(ctx); super.prepareMarshal(ctx);


if (keyBytes == null) prepareMarshalCacheObjects(keys, ctx);
keyBytes = marshalCollection(keys, ctx);
} }


/** {@inheritDoc} */ /** {@inheritDoc} */
@Override public void finishUnmarshal(GridCacheSharedContext ctx, ClassLoader ldr) throws IgniteCheckedException { @Override public void finishUnmarshal(GridCacheSharedContext ctx, ClassLoader ldr) throws IgniteCheckedException {
super.finishUnmarshal(ctx, ldr); super.finishUnmarshal(ctx, ldr);


if (keys == null) finishUnmarshalCacheObjects(keys, ctx, ldr);
keys = unmarshalCollection(keyBytes, ctx, ldr);
} }


/** /**
* @return Key count. * @return Key count.
*/ */
private int keyCount() { private int keyCount() {
return keyBytes == null ? keys.size() : keyBytes.size(); return keys.size();
} }


/** {@inheritDoc} */ /** {@inheritDoc} */
Expand All @@ -183,7 +170,7 @@ private int keyCount() {
writer.incrementState(); writer.incrementState();


case 4: case 4:
if (!writer.writeCollection("keyBytes", keyBytes, MessageCollectionItemType.BYTE_ARR)) if (!writer.writeCollection("keys", keys, MessageCollectionItemType.MSG))
return false; return false;


writer.incrementState(); writer.incrementState();
Expand Down Expand Up @@ -225,7 +212,7 @@ private int keyCount() {
reader.incrementState(); reader.incrementState();


case 4: case 4:
keyBytes = reader.readCollection("keyBytes", MessageCollectionItemType.BYTE_ARR); keys = reader.readCollection("keys", MessageCollectionItemType.MSG);


if (!reader.isLastRead()) if (!reader.isLastRead())
return false; return false;
Expand Down
Expand Up @@ -42,23 +42,16 @@ public class GridDhtForceKeysResponse extends GridCacheMessage implements GridCa
/** Mini-future ID. */ /** Mini-future ID. */
private IgniteUuid miniId; private IgniteUuid miniId;


/** */
@GridDirectCollection(byte[].class)
private Collection<byte[]> missedKeyBytes;

/** Missed (not found) keys. */ /** Missed (not found) keys. */
@GridToStringInclude @GridToStringInclude
@GridDirectTransient @GridDirectCollection(KeyCacheObject.class)
private Collection<KeyCacheObject> missedKeys; private List<KeyCacheObject> missedKeys;


/** Cache entries. */ /** Cache entries. */
@GridToStringInclude @GridToStringInclude
@GridDirectTransient @GridDirectCollection(GridCacheEntryInfo.class)
private List<GridCacheEntryInfo> infos; private List<GridCacheEntryInfo> infos;


/** */
private byte[] infosBytes;

/** /**
* Required by {@link Externalizable}. * Required by {@link Externalizable}.
*/ */
Expand Down Expand Up @@ -140,27 +133,27 @@ public void addInfo(GridCacheEntryInfo info) {
@Override public void prepareMarshal(GridCacheSharedContext ctx) throws IgniteCheckedException { @Override public void prepareMarshal(GridCacheSharedContext ctx) throws IgniteCheckedException {
super.prepareMarshal(ctx); super.prepareMarshal(ctx);


if (missedKeys != null && missedKeyBytes == null) if (missedKeys != null)
missedKeyBytes = marshalCollection(missedKeys, ctx); prepareMarshalCacheObjects(missedKeys, ctx);


if (infos != null) { if (infos != null) {
marshalInfos(infos, ctx); for (GridCacheEntryInfo info : infos)

info.marshal(ctx);
infosBytes = ctx.marshaller().marshal(infos);
} }
} }


/** {@inheritDoc} */ /** {@inheritDoc} */
@Override public void finishUnmarshal(GridCacheSharedContext ctx, ClassLoader ldr) throws IgniteCheckedException { @Override public void finishUnmarshal(GridCacheSharedContext ctx, ClassLoader ldr) throws IgniteCheckedException {
super.finishUnmarshal(ctx, ldr); super.finishUnmarshal(ctx, ldr);


if (missedKeys == null && missedKeyBytes != null) if (missedKeys != null)
missedKeys = unmarshalCollection(missedKeyBytes, ctx, ldr); finishUnmarshalCacheObjects(missedKeys, ctx, ldr);


if (infosBytes != null) { if (infos != null) {
infos = ctx.marshaller().unmarshal(infosBytes, ldr); GridCacheContext cctx = ctx.cacheContext(cacheId);


unmarshalInfos(infos, ctx.cacheContext(cacheId()), ldr); for (GridCacheEntryInfo info : infos)
info.unmarshal(cctx, ldr);
} }
} }


Expand All @@ -186,7 +179,7 @@ public void addInfo(GridCacheEntryInfo info) {
writer.incrementState(); writer.incrementState();


case 4: case 4:
if (!writer.writeByteArray("infosBytes", infosBytes)) if (!writer.writeCollection("infos", infos, MessageCollectionItemType.MSG))
return false; return false;


writer.incrementState(); writer.incrementState();
Expand All @@ -198,7 +191,7 @@ public void addInfo(GridCacheEntryInfo info) {
writer.incrementState(); writer.incrementState();


case 6: case 6:
if (!writer.writeCollection("missedKeyBytes", missedKeyBytes, MessageCollectionItemType.BYTE_ARR)) if (!writer.writeCollection("missedKeys", missedKeys, MessageCollectionItemType.MSG))
return false; return false;


writer.incrementState(); writer.incrementState();
Expand Down Expand Up @@ -228,7 +221,7 @@ public void addInfo(GridCacheEntryInfo info) {
reader.incrementState(); reader.incrementState();


case 4: case 4:
infosBytes = reader.readByteArray("infosBytes"); infos = reader.readCollection("infos", MessageCollectionItemType.MSG);


if (!reader.isLastRead()) if (!reader.isLastRead())
return false; return false;
Expand All @@ -244,7 +237,7 @@ public void addInfo(GridCacheEntryInfo info) {
reader.incrementState(); reader.incrementState();


case 6: case 6:
missedKeyBytes = reader.readCollection("missedKeyBytes", MessageCollectionItemType.BYTE_ARR); missedKeys = reader.readCollection("missedKeys", MessageCollectionItemType.MSG);


if (!reader.isLastRead()) if (!reader.isLastRead())
return false; return false;
Expand Down
Expand Up @@ -120,7 +120,7 @@ public IgniteUuid miniId() {
* @return Entries. * @return Entries.
*/ */
public Collection<GridCacheEntryInfo> entries() { public Collection<GridCacheEntryInfo> entries() {
return entries; return entries != null ? entries : Collections.<GridCacheEntryInfo>emptyList();
} }


/** /**
Expand Down
Expand Up @@ -133,6 +133,7 @@ public interface GridPortableProcessor extends GridProcessor {


/** /**
* @param obj Portable object to get field from. * @param obj Portable object to get field from.
* @param fieldName Field name.
* @return Field value. * @return Field value.
*/ */
public Object field(Object obj, String fieldName); public Object field(Object obj, String fieldName);
Expand All @@ -153,8 +154,8 @@ public interface GridPortableProcessor extends GridProcessor {
@Nullable public CacheObject toCacheObject(@Nullable Object obj); @Nullable public CacheObject toCacheObject(@Nullable Object obj);


/** /**
* @param obj Object. * @param obj Key value.
* @return Cache object. * @return Cache key object.
*/ */
@Nullable public KeyCacheObject toCacheKeyObject(@Nullable Object obj); public KeyCacheObject toCacheKeyObject(Object obj);
} }

0 comments on commit 7d31dde

Please sign in to comment.