Skip to content

Commit

Permalink
Virtual apps bad performance #10015
Browse files Browse the repository at this point in the history
  • Loading branch information
rymsha committed Mar 14, 2023
1 parent 3cf7fb3 commit a3c6b9d
Show file tree
Hide file tree
Showing 97 changed files with 982 additions and 1,228 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ protected WebResponse doHandle( final WebRequest webRequest, final WebResponse w
}

trace.put( "path", webRequest.getPath() );
trace.put( "method", webRequest.getMethod().toString() );
trace.put( "method", webRequest.getMethod() );
trace.put( "host", webRequest.getHost() );
trace.put( "httpRequest", webRequest );
trace.put( "httpResponse", webResponse );
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.enonic.xp.internal.blobstore.file;

import java.io.IOException;
import java.io.UncheckedIOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Objects;
Expand Down Expand Up @@ -39,7 +40,7 @@ public long getLength()
}
catch ( IOException e )
{
return 0;
throw new UncheckedIOException( e );
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import com.google.common.base.Preconditions;

public class NodeVersionKey
public final class NodeVersionKey
{
private final BlobKey nodeBlobKey;

Expand Down Expand Up @@ -41,7 +41,7 @@ public boolean equals( final Object o )
{
return true;
}
if ( o == null || getClass() != o.getClass() )
if ( !( o instanceof NodeVersionKey ) )
{
return false;
}
Expand All @@ -58,11 +58,10 @@ public int hashCode()

public static NodeVersionKey from( final BlobKey nodeBlobKey, final BlobKey indexConfigBlobKey, final BlobKey accessControlBlobKey )
{
return create().
nodeBlobKey( nodeBlobKey ).
indexConfigBlobKey( indexConfigBlobKey ).
accessControlBlobKey( accessControlBlobKey ).
build();
return create().nodeBlobKey( nodeBlobKey )
.indexConfigBlobKey( indexConfigBlobKey )
.accessControlBlobKey( accessControlBlobKey )
.build();
}

public static NodeVersionKey from( final String nodeBlobKey, final String indexConfigBlobKey, final String accessControlBlobKey )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,7 @@ public boolean isPageTemplate()
return this instanceof PageTemplate;
}

@Deprecated
public boolean hasPage()
{
return page != null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public EditableContent( final Content source )
this.displayName = source.getDisplayName();
this.data = source.getData().copy();
this.extraDatas = source.getAllExtraData().copy();
this.page = source.hasPage() ? source.getPage().copy() : null;
this.page = source.getPage() != null ? source.getPage().copy() : null;
this.valid = source.isValid();
this.thumbnail = source.getThumbnail();
this.inheritPermissions = source.inheritsPermissions();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ public final class PropertyPath

private final boolean relative;

private final PropertyPath parentPath;

public static PropertyPath from( final PropertyPath parentPath, final String element )
{
Preconditions.checkNotNull( parentPath, "parentPath cannot be null" );
Expand Down Expand Up @@ -83,7 +81,6 @@ private PropertyPath()
{
this.elements = ImmutableList.of();
this.relative = false;
this.parentPath = null;
}

private PropertyPath( final ImmutableList<Element> pathElements )
Expand All @@ -92,23 +89,12 @@ private PropertyPath( final ImmutableList<Element> pathElements )

this.elements = pathElements;
this.relative = this.elements.isEmpty() || !this.elements.get( 0 ).getName().startsWith( ELEMENT_DIVIDER );

final List<Element> parentPathElements = new ArrayList<>();
for ( int i = 0; i < this.elements.size(); i++ )
{
if ( i < this.elements.size() - 1 )
{
parentPathElements.add( this.elements.get( i ) );
}
}
this.parentPath = parentPathElements.isEmpty() ? null :PropertyPath.from( parentPathElements );
}

private PropertyPath( final PropertyPath parentPath, final Element element )
{
Preconditions.checkNotNull( parentPath, "parentPath cannot be null" );
Preconditions.checkNotNull( element, "element cannot be null" );
this.parentPath = parentPath;

final ImmutableList.Builder<Element> elementBuilder = ImmutableList.builder();
elementBuilder.addAll( parentPath.pathElements() ).add( element );
Expand All @@ -118,7 +104,7 @@ private PropertyPath( final PropertyPath parentPath, final Element element )

public PropertyPath getParent()
{
return parentPath;
return this.elements.size() <= 1 ? null : PropertyPath.from( this.elements.subList( 0, this.elements.size() - 1 ) );
}

public boolean isRelative()
Expand Down Expand Up @@ -203,9 +189,9 @@ public PropertyPath removeFirstPathElement()
public PropertyPath removeIndexFromLastElement()
{

if ( this.parentPath != null )
if ( this.elements.size() > 1 )
{
return PropertyPath.from( this.parentPath, this.getLastElement().getName() );
return PropertyPath.from( this.getParent(), this.getLastElement().getName() );
}
else
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.enonic.xp.index;

import java.util.Objects;

import com.enonic.xp.annotation.PublicApi;

@PublicApi
Expand All @@ -19,6 +21,27 @@ public String getAnalyzer()
return this.analyzer;
}

@Override
public boolean equals( final Object o )
{
if ( this == o )
{
return true;
}
if ( o == null || getClass() != o.getClass() )
{
return false;
}
final AbstractIndexConfigDocument that = (AbstractIndexConfigDocument) o;
return Objects.equals( analyzer, that.analyzer );
}

@Override
public int hashCode()
{
return Objects.hash( analyzer );
}

static class Builder<B extends Builder>
{
private String analyzer;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
package com.enonic.xp.index;

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

import com.google.common.collect.ImmutableList;

public final class AllTextIndexConfig
{
private final List<String> languages;
private final ImmutableList<String> languages;

private AllTextIndexConfig( final Builder builder )
private AllTextIndexConfig( final ImmutableList<String> languages )
{
this.languages = ImmutableList.copyOf( builder.languages );
this.languages = languages;
}

public static Builder create()
Expand All @@ -30,38 +28,31 @@ public List<String> getLanguages()
return languages;
}


@Override
public boolean equals( final Object o )
{
if ( this == o )
{
return true;
}
if ( o == null || getClass() != o.getClass() )
{
return false;
}
final AllTextIndexConfig that = (AllTextIndexConfig) o;
return Objects.equals( languages, that.languages );
return this == o || o instanceof AllTextIndexConfig && languages.equals( ( (AllTextIndexConfig) o ).languages );
}

@Override
public int hashCode()
{
return Objects.hash( languages );
return languages.hashCode();
}

public static class Builder
{
private List<String> languages = new ArrayList<>();
private final ImmutableList.Builder<String> languages;

Builder()
{
languages = ImmutableList.builder();
}

Builder( final AllTextIndexConfig source )
{
this.languages = new ArrayList<>( source.languages );
this.languages = ImmutableList.<String>builder().addAll( source.languages );
}

public Builder addLanguage( final String language )
Expand All @@ -72,7 +63,7 @@ public Builder addLanguage( final String language )

public AllTextIndexConfig build()
{
return new AllTextIndexConfig( this );
return new AllTextIndexConfig( languages.build() );
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import static com.google.common.base.Strings.nullToEmpty;

@PublicApi
public class PatternIndexConfigDocument
public final class PatternIndexConfigDocument
extends AbstractIndexConfigDocument
{
private final ImmutableSortedSet<PathIndexConfig> pathIndexConfigs;
Expand Down Expand Up @@ -105,22 +105,23 @@ public boolean equals( final Object o )
{
return true;
}
if ( !( o instanceof PatternIndexConfigDocument ) )
if ( o == null || getClass() != o.getClass() )
{
return false;
}

final PatternIndexConfigDocument that = (PatternIndexConfigDocument) o;

if ( !Objects.equals( defaultConfig, that.defaultConfig ) )
if ( !super.equals( o ) )
{
return false;
}
if ( !Objects.equals( pathIndexConfigs, that.pathIndexConfigs ) )
{
return false;
}
return Objects.equals( this.allTextConfig, that.allTextConfig );
final PatternIndexConfigDocument that = (PatternIndexConfigDocument) o;
return Objects.equals( pathIndexConfigs, that.pathIndexConfigs ) &&
Objects.equals( defaultConfig, that.defaultConfig ) && Objects.equals( allTextConfig, that.allTextConfig );
}

@Override
public int hashCode()
{
return Objects.hash( super.hashCode(), pathIndexConfigs, defaultConfig, allTextConfig );
}

public static final class Builder
Expand Down Expand Up @@ -209,12 +210,4 @@ public PatternIndexConfigDocument build()
return new PatternIndexConfigDocument( this );
}
}

@Override
public int hashCode()
{
int result = pathIndexConfigs != null ? pathIndexConfigs.hashCode() : 0;
result = 31 * result + ( defaultConfig != null ? defaultConfig.hashCode() : 0 );
return result;
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.enonic.xp.node;

import java.util.Collection;
import java.util.HashSet;
import java.util.Set;

import com.google.common.collect.ImmutableSet;
Expand Down Expand Up @@ -56,7 +55,7 @@ public static Builder create()

public static class Builder
{
private final Set<AttachedBinary> nodeAttachedBinaries = new HashSet<>();
private final ImmutableSet.Builder<AttachedBinary> nodeAttachedBinaries = ImmutableSet.builder();

public Builder add( final AttachedBinary attachedBinary )
{
Expand All @@ -67,12 +66,12 @@ public Builder add( final AttachedBinary attachedBinary )
@Deprecated
public Set<AttachedBinary> getNodeAttachedBinaries()
{
return nodeAttachedBinaries;
return nodeAttachedBinaries.build();
}

public AttachedBinaries build()
{
return fromInternal( ImmutableSet.copyOf( nodeAttachedBinaries ) );
return fromInternal( nodeAttachedBinaries.build() );
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,7 @@ public String getName()
@Override
public boolean equals( final Object o )
{
if ( this == o )
{
return true;
}
if ( o == null || getClass() != o.getClass() )
{
return false;
}

final NodeType that = (NodeType) o;

return name.equals( that.name );
return this == o || o instanceof NodeType && name.equals( ( (NodeType) o ).name );
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,31 +115,35 @@ public static final class Builder
{
private NodeId id;

private NodeType nodeType = NodeType.DEFAULT_NODE_COLLECTION;
private NodeType nodeType;

private PropertyTree data = new PropertyTree();
private PropertyTree data;

private IndexConfigDocument indexConfigDocument;

private ChildOrder childOrder;

private Long manualOrderValue;

private AccessControlList permissions = AccessControlList.empty();
private AccessControlList permissions;

private boolean inheritPermissions;

private AttachedBinaries attachedBinaries = AttachedBinaries.empty();
private AttachedBinaries attachedBinaries;

private Builder()
{
this.nodeType = NodeType.DEFAULT_NODE_COLLECTION;
this.data = new PropertyTree();
permissions = AccessControlList.empty();
attachedBinaries = AttachedBinaries.empty();
}

private Builder( NodeVersion nodeVersion )
{
this.id = nodeVersion.id;
this.nodeType = nodeVersion.nodeType;
this.data = nodeVersion.data;
this.data = nodeVersion.data.copy();
this.indexConfigDocument = nodeVersion.indexConfigDocument;
this.childOrder = nodeVersion.childOrder;
this.manualOrderValue = nodeVersion.manualOrderValue;
Expand Down
Loading

0 comments on commit a3c6b9d

Please sign in to comment.