Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SONAR-6089 Only clear lookup cache of current View
- Loading branch information
1 parent
8f1b67e
commit 3601d3a
Showing
17 changed files
with
404 additions
and
198 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
96 changes: 96 additions & 0 deletions
96
...sonar-server/src/main/java/org/sonar/server/es/request/ProxyClearCacheRequestBuilder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,96 @@ | |||
/* | |||
* SonarQube, open source software quality management tool. | |||
* Copyright (C) 2008-2014 SonarSource | |||
* mailto:contact AT sonarsource DOT com | |||
* | |||
* SonarQube 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 3 of the License, or (at your option) any later version. | |||
* | |||
* SonarQube 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 program; if not, write to the Free Software Foundation, | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
|
|||
package org.sonar.server.es.request; | |||
|
|||
import org.apache.commons.lang.StringUtils; | |||
import org.elasticsearch.action.ListenableActionFuture; | |||
import org.elasticsearch.action.admin.indices.cache.clear.ClearIndicesCacheRequestBuilder; | |||
import org.elasticsearch.action.admin.indices.cache.clear.ClearIndicesCacheResponse; | |||
import org.elasticsearch.client.Client; | |||
import org.elasticsearch.common.unit.TimeValue; | |||
import org.sonar.core.profiling.Profiling; | |||
import org.sonar.core.profiling.StopWatch; | |||
|
|||
public class ProxyClearCacheRequestBuilder extends ClearIndicesCacheRequestBuilder { | |||
|
|||
private final Profiling profiling; | |||
|
|||
public ProxyClearCacheRequestBuilder(Client client, Profiling profiling) { | |||
super(client.admin().indices()); | |||
this.profiling = profiling; | |||
} | |||
|
|||
@Override | |||
public ClearIndicesCacheResponse get() { | |||
StopWatch fullProfile = profiling.start("clear cache", Profiling.Level.FULL); | |||
try { | |||
return super.execute().actionGet(); | |||
} catch (Exception e) { | |||
throw new IllegalStateException(String.format("Fail to execute %s", toString()), e); | |||
} finally { | |||
if (profiling.isProfilingEnabled(Profiling.Level.FULL)) { | |||
fullProfile.stop("%s", toString()); | |||
} | |||
} | |||
} | |||
|
|||
@Override | |||
public ClearIndicesCacheResponse get(TimeValue timeout) { | |||
throw new IllegalStateException("Not yet implemented"); | |||
} | |||
|
|||
@Override | |||
public ClearIndicesCacheResponse get(String timeout) { | |||
throw new IllegalStateException("Not yet implemented"); | |||
} | |||
|
|||
@Override | |||
public ListenableActionFuture<ClearIndicesCacheResponse> execute() { | |||
throw new UnsupportedOperationException("execute() should not be called as it's used for asynchronous"); | |||
} | |||
|
|||
@Override | |||
public String toString() { | |||
StringBuilder message = new StringBuilder(); | |||
message.append("ES clear cache request"); | |||
if (request.indices().length > 0) { | |||
message.append(String.format(" on indices '%s'", StringUtils.join(request.indices(), ","))); | |||
} | |||
String[] fields = request.fields(); | |||
if (fields != null && fields.length > 0) { | |||
message.append(String.format(" on fields '%s'", StringUtils.join(fields, ","))); | |||
} | |||
String[] filterKeys = request.filterKeys(); | |||
if (filterKeys != null && filterKeys.length > 0) { | |||
message.append(String.format(" on filterKeys '%s'", StringUtils.join(filterKeys, ","))); | |||
} | |||
if (request.filterCache()) { | |||
message.append(" with filter cache"); | |||
} | |||
if (request.fieldDataCache()) { | |||
message.append(" with field data cache"); | |||
} | |||
if (request.idCache()) { | |||
message.append(" with id cache"); | |||
} | |||
return message.toString(); | |||
} | |||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.