Menu
  • HOME
  • TAGS

ehCache Statistics with spring boot

Tag: statistics,spring-boot,ehcache

I have spring boot application with ehcache as below

@Bean
public EhCacheManagerFactoryBean ehCacheManagerFactoryBean() {

    EhCacheManagerFactoryBean ehCacheManagerFactoryBean = new EhCacheManagerFactoryBean();
    ehCacheManagerFactoryBean.setConfigLocation(new ClassPathResource("ehcache.xml"));
    //ehCacheManagerFactoryBean.setCacheManagerName("messageCache");
    ehCacheManagerFactoryBean.setShared(true);
    return ehCacheManagerFactoryBean;
}

@Bean
public EhCacheCacheManager cacheManager() {
    return new EhCacheCacheManager(ehCacheManagerFactoryBean().getObject());
}

I also put @EnableCaching on root configuration file

for ehcache.xml i have the below

<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xsi:noNamespaceSchemaLocation="ehcache.xsd"
 updateCheck="true" monitoring="autodetect" dynamicConfig="true">

<diskStore path="java.io.tmpdir" />

<defaultCache maxEntriesLocalHeap="10000" eternal="false"
    timeToIdleSeconds="120" timeToLiveSeconds="120" maxEntriesLocalDisk="10000000"
    diskExpiryThreadIntervalSeconds="120" statistics="true">
</defaultCache>

<cache name="mediumCache"
       maxEntriesLocalHeap="2000"
       eternal="false"
       timeToIdleSeconds="1800"
       timeToLiveSeconds="3600"
       overflowToDisk="false"
       memoryStoreEvictionPolicy="LFU" statistics="true"
    />

<cache name="highCache"
       maxEntriesLocalHeap="2000"
       eternal="false"
       timeToIdleSeconds="3600"
       timeToLiveSeconds="7200"
       overflowToDisk="false"
       memoryStoreEvictionPolicy="LFU" statistics="true"
    />

-->

Every thing is good and my cachable function are working good , now i want to see the statistics with spring-actuator in metric .

How can we do that ?

Best How To :

If you can afford to use a snapshot release of spring boot this feature is being added to 1.3.0. Right now you won't get that in 1.2.X

spring boot switching from in-memory database to persistent database

intellij-idea,spring-boot,spring-data

You can change the application properties for the datasource according to the link Gabor Bakos already provided. That depends on the type of the database you want to use. HSQLDB and H2 allow you to specify a file path for the database file, however the database instance itself is...

Histogram-like summary for interval data

r,statistics,histogram

Using IRanges, you should use findOverlaps or mergeByOverlaps instead of countOverlaps. It, by default, doesn't return no matches though. I'll leave that to you. Instead, will show an alternate method using foverlaps() from data.table package: require(data.table) subject <- data.table(interval = paste("int", 1:4, sep=""), start = c(2,10,12,25), end = c(7,14,18,28)) query...

Can't use scipy stats function on nested list

python,numpy,statistics,scipy,nested-lists

You need to apply it on a numpy.array reflecting the nested lists. from scipy import stats import numpy as np dataset = np.array([[1.5,3.3,2.6,5.8],[1.5,3.2,5.6,1.8],[2.5,3.1,3.6,5.2]]) stats.mstats.zscore(dataset) works fine....

Getting a lost Sentinel error message for Redis

redis,spring-boot,spring-data-redis

We discovered the issue. There was a blank between the node pairs in the application.yml and once we removed this " " the Lost Sentinel log message disappeared. so from nodes: 10.202.56.209:26379, 10.202.56.213:26379, 10.202.58.80:26379 to nodes: 10.202.56.209:26379,10.202.56.213:26379,10.202.58.80:26379 It would probably be a good thing is the committers looked at this...

How to access spring.application.instance_id programatically?

java,spring,spring-boot,spring-cloud,netflix-eureka

You miss metadata block. Use: @Value("${eureka.instance.metadataMap.instanceId}") String instanceId; As far as I know there is no instance_id property in spring.application namespace....

How to not-abbreviate the source class name in spriing-boot's loggger name?

log4j,spring-boot

By default Spring boot uses Logback logging. You can change the configuration by putting a logback.xml file in your class path. They have a default base.xml which defines the overall configuration and includes their defaults.xml file. Because of where the log pattern is defined you will need to created a...

Spring Boot REST display id of parent only in a JSON response

json,spring,rest,spring-boot

Basically returning entities directly from endpoints isn't a good idea. You make very tight coupling between DB model and responses. Instead, implement a POJO class that will be equivalent of the HTTP response you sent. This POJO will have all ChildEntity fields and parentId only and will be constructed in...

Spring Cloud Config Globals

java,spring,spring-boot,spring-cloud

According to the documentation properties in application.yml or application.properties are available to every application.

spring-boot integration testing using rest-assured

maven,spring-boot,h2

Are you using Eclipse? I somehow noticed that src/main/resources/application.properties gets excluded from the Java Build Path, if you generate the project with the "eclipse:eclipse" maven goal. To workaround this you can either add a src/test/resources/application.properties or correct the Java Build Path. I don't know if this behavior is intended. I...

set an annotation attribute from an environment variable?

spring,groovy,spring-boot

You can not use GStrings in java annotations in groovy. You have to use "proper" Strings. E.g. @Scheduled(cron = '${DB_CRON}') Note the single quotes here. If groovy sees a $ in "-quoted string, it will turn it into a GString. This can not be done with java annotations and you...

Jsp list output [email protected]?

jsp,spring-mvc,spring-boot

There are two things I see wrong. First if your code is really as posted and not a typo, than you should note that you don't print anything inside a loop as you just iterate and never do anything with the user variable The following <c:forEach items = "${tweets}" var="user"...

How to access entity manager with spring boot and spring data

spring-boot,spring-data,spring-data-jpa

You would define a CustomRepository to handle such scenarios. Consider you have CustomerRepository which extends the default spring data JPA interface JPARepository<Customer,Long> Create a new interface CustomCustomerRepository with a custom method signatures. public interface CustomCustomerRepository { public void customMethod(); } Extend CustomerRepository interface using CustomCustomerRepository public interface CustomerRepository extends JpaRepository<Customer,...

Spring Data Rest executes query but returns 500 internal Server Error

java,spring,rest,spring-boot,spring-data-rest

Hum... This is strange but I found this question and added a controller to call the method and it worked like a charm... Obv this is not a fix, but it is a good workaround... EDIT: The error happens because it is expecting an entity, so all I had to...

how to Autowire the applicationContext early?

spring,spring-boot

static fields are ignored by Spring. Unless you're in some kind of main method, setting up your application, you should never have to use the ApplicationContext directly. Here, you want to use it to extract a bean of type IWCustomerService. Instead, let Spring inject it for you. @Bean public EndpointImpl...

Spring Boot War file gets 404 on ec2

tomcat,amazon-ec2,spring-boot,.war

I've answered a similar question here. You are running your external tomcat under a Java 1.7 JRE, while having compiled your code against 1.8. Strangely, there is no error, and the app appears in the manager app, but then you get a 404 when you're trying to access it. One...

Spring Boot extending CrudRepository

java,spring,hibernate,spring-boot,spring-data-jpa

There are lots of ways you could probably accomplish this. If you really need absolute control try this interface FoobarRepositoryCustom{ List<Foobar> findFoobarsByDate(Date date); } interface FoobarRepository extends CrudRepository<Foobar, Long>, FoobarRepositoryCustom public FoobarRespoitoryImpl implements FoobarRepositoryCustom{ @PersistenceContext private EntityManager em; public List<Foobar> findFoobarsByDate(Date date) { String sql = "select fb from Foobar...

Removing a prior sample while using Welford's method for computing single pass variance

algorithm,math,statistics,variance,standard-deviation

Given the forward formulas Mk = Mk-1 + (xk – Mk-1) / k Sk = Sk-1 + (xk – Mk-1) * (xk – Mk), it's possible to solve for Mk-1 as a function of Mk and xk and k: Mk-1 = Mk - (xk - Mk) / (k - 1)....

disable RabbitAutoConfiguration programmatically

spring,spring-boot

First you need to exclude RabbitAutonfiguration from your app @EnableAutoConfiguration(exclude=RabbitAutoConfiguration.class) Then you can import it based on some property like this @Configuration @ConditionalOnProperty(name="myproperty",havingValue="valuetocheck",matchIfMissing=false) @Import(RabbitAutoConfiguration.class) class RabbitOnConditionalConfiguration{ } ...

Why is my Spring Boot autowired JPA Repository failing JUnit test?

java,spring,junit,spring-boot

Exception comes from this line: ReflectionTestUtils.setField(userResource, "userRepository", userRepository); Second parameter of setField method is a field name. UserResource has field "repository" - not "userRepository" as you try to set in your test....

Normal probability density function - GSL equivalent in Haskell

haskell,statistics,gsl

Here's an example which uses random-fu: import Data.Random -- for randomness import Text.Printf -- for printf import Data.Foldable -- for the for_ loop -- pdf and cdf are basically “Distribution -> Double -> Double” main = do -- defining normal distribution with mean = 10 and variation = 2 let...

Not Able to Resolve View Using Spring boot

spring,spring-mvc,spring-boot

Here could be two issues one them are dependencies. 1.These three dependencies could help you: <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-tomcat</artifactId> </dependency> <dependency> <groupId>org.apache.tomcat.embed</groupId> <artifactId>tomcat-embed-jasper</artifactId> </dependency> <dependency> <groupId>javax.servlet</groupId> <artifactId>jstl</artifactId>...

getting 401 to access http://localhost:8080/oauth/token

java,javascript,angularjs,oauth,spring-boot

In case of OPTIONS request, you should not do further processing, i.e. skip the call to chain.doFilter(req, res), e.g.: HttpServletRequest request = (HttpServletRequest) req; HttpServletResponse response = (HttpServletResponse) resp; response.addHeader("Access-Control-Allow-Origin", "*"); if ("OPTIONS".equalsIgnoreCase(request.getMethod())) { response.setHeader("Access-Control-Allow-Methods", "POST,GET,DELETE"); response.setHeader("Access-Control-Max-Age", "3600"); response.setHeader("Access-Control-Allow-Headers",...

How to Fetch Data using Spring Data

spring,jpa,spring-boot,spring-data

You want to find all books for a specific author so, given an Author, retrieve all Books whose set of Authors contains the specified Author. The relevant JPQL operator is: http://www.objectdb.com/java/jpa/query/jpql/collection#NOT_MEMBER_OF_ [NOT] MEMBER [OF] The [NOT] MEMBER OF operator checks if a specified element is contained in a specified persistent...

Avoid inserting duplicates into MySQL while reading an excel file using spring boot

java,mysql,excel,spring-boot

Why not use the exists() method instead of what you are doing? That is what it is there for. boolean exists(ID id) Returns whether an entity with the given id exists. if(!te.exits(wb.getSheetName(i))){ TableEntity t=new TableEntity(wb.getSheetName(i), ""); te.save(t) } ...

Dynamic fields thymeleaf list iteration

spring,spring-mvc,spring-boot,thymeleaf

Actually when binding fields to a form, in order to acces to a list with th:each. As the doc specify, we should use the two variable item, and phoneStat this way and not just phoneStat : <div th:each="item, phoneStat : *{phones}"> <select th:field="*{phones[__${phoneStat.index}__].variety}" > <option> </option> </select> <div class=" input-field...

How should I use @Cacheable on spring data repositories

java,spring-boot,spring-data

Not sure how you're actually using MongoRepository, you seem to suggest you're using it directly (it's often a good idea to include your code in the question), but the reference documentation explains the basics of working with this interface (and all repository interfaces in Spring Data, as a matter of...

Springboot REST application should accept and produce both XML and JSON

java,xml,rest,jackson,spring-boot

Try to add a @XmlRootElement(name="myRootTag") JAXB annotation with the tag you use as the root tag to the class MatchRequest. I have had similar issues when using both XML and JSON as transport format in a REST request, but using moxy instead of Jackson. In any case, proper JAXB annotations...

Extract data from excel to mysql in java

java,spring-boot

I assume it's the usage of < sheet.getLastRowNum() for your first for loop: getLastRowNum() --> last row contained n this sheet (0-based) (see https://poi.apache.org/apidocs/org/apache/poi/xssf/usermodel/XSSFSheet.html#getLastRowNum()) Hence this is NOT the number of rows, but the index of the last row! So, if you have 2 rows, this will return 1, since...

Mock class inside REST controller with Mockito

java,testing,junit,spring-boot,mockito

Shouldn't you be passing an instance to set the field on, rather than the class, e.g.: ... @Autowired private Controller controller; ... @Before public void setUp() throws Exception { ... Processor processor = Mockito.mock(Processor.class); ReflectionTestUtils.setField(controller, "processor", processor); } ...

How to run flyway:clean before migrations in a SpringBoot app?

spring-boot,flyway

You can overwrite the Flyway autoconfiguration like this: @Bean @Profile("test") public Flyway flyway(DataSource theDataSource) { Flyway flyway = new Flyway(); flyway.setDataSource(theDataSource); flyway.setLocations("classpath:db/migration"); flyway.clean(); flyway.migrate(); return flyway; } In Spring Boot 1.3 (current version is 1.3.0.M1, GA release is planned for September), you can use a FlywayMigrationStrategy bean to define the...

Possible to use Spring Boot 1.3.0.M1 with Spring Cloud?

spring-boot,spring-cloud

There is an open issue to support Spring Boot 1.3.0.

Disaggregate one row of data to multiple rows

r,excel,statistics,dataset,google-adwords

Try library(data.table) setDT(df1)[, list(Clicked=rep(c(1,0), c(Clicks, Impressions-Clicks)), Converted=rep(c(1,0), c(Conversions, Impressions-Conversions))) , Keyword] # Keyword Clicked Converted # 1: SampleName 1 1 # 2: SampleName 1 1 # 3: SampleName 1 0 # 4: SampleName 1 0 # 5: SampleName 1 0 # 6: SampleName 0 0 # 7: SampleName 0 0...

Adding external static files (css, js, png …) in spring boot

java,spring,spring-mvc,spring-boot,thymeleaf

You can use resource handlers to serve external files - e.g. @Component class WebConfigurer extends WebMvcConfigurerAdapter { @Override public void addResourceHandlers(ResourceHandlerRegistry registry) { registry.addResourceHandler("/ext/**").addResourceLocations("file:///yourPath/static/"); } } ...

Trouble with Login using Spring Boot and JDBC Security

spring,spring-security,spring-boot

There are 2 things flawed in your setup. You should post to /login instead of /j_spring_security_check as that is the new URL when using java config (and in Spring 4 for XML config also). You have set the usernameParameter to name and your form still has username. Fix those flaws...

How to apply HandlerInterceptor to Spring Boot Actuator endpoints?

java,spring,spring-mvc,spring-boot

You can use an EndpointHandlerMappingCustomizer to configure the interceptors of the Actuator's endpoints. For example: @Bean public EndpointHandlerMappingCustomizer mappingCustomizer() { return new EndpointHandlerMappingCustomizer() { @Override public void customize(EndpointHandlerMapping mapping) { mapping.setInterceptors(new Object[] { application.executeTimeInterceptor() }); } }; } ...

Matlab: What are the ways to determine the distribution of the data

matlab,statistics,distribution

If I understand correctly, you are asking how to decide which distribution to choose once you have a few fits. There are three major metrics (IMO) for measuring "goodness-of-fit": Chi-Squared Kolmogrov-Smirnov Anderson-Darling Which to choose depends on a large number of factors; you can randomly pick one or read the...

How to explain a higher percentage of point variability using kmeans clustering? [closed]

r,statistics,cluster-analysis,k-means

The amount of variance explained is related to the two principal components calculated to visualize your data. This has nothing to do with the type of clustering algorithm or the accuracy of the algorithm that you're using (kmeans in this case). To understand how accurate your clustering algorithm is at...

R: how to use the bpower function to calculate 2-sample binomial test power

r,statistics

The signature for the function is args(bpower) # function (p1, p2, odds.ratio, percent.reduction, n, n1, n2, alpha = 0.05) so if unnamed, the third parameter will be interpreted as the odds ratio. So yes, you made a mistake in your code. You should explicitly name your parameters to avoid this...

Get a variables value from one dataset if falling in a range defined by two variables in another dataset in R

r,date,statistics,dataset

Here a solution based on the excellent foverlaps of the data.table package. library(data.table) ## coerce characters to dates ( numeric) setDT(x)[,c("date1","date2"):=list(as.Date(date1,"%d/%m/%Y"), as.Date(date2,"%d/%m/%Y"))] ## and a dummy date since foverlaps looks for a start,end columns setDT(y)[,c("date1"):=as.Date(date,"%d/%m/%Y")][,date:=date1] ## y must be keyed setkey(y,id,date,date1) foverlaps(x,y,by.x=c("id","date1","date2"))[, list(id,i.date1,date2,date,price)] id i.date1 date2 date price 1: A...

“Icon” (ISOTYPE) charts in R shiny with Javascript

javascript,r,plot,statistics,shiny

Answering my own question since, after all, I have found some resources that fit my use case and they seem viable for development. Hopefully it'll come in handy for the comunity later down the road :) After further investigation, I found the name of "pictogram charts" as an alternative way...

Spring: @NestedConfigurationProperty List in @ConfigurationProperties

spring,properties,configuration,spring-boot

You need to add setters and getters to ServerConfiguration You don't need to annotate class with nested properties with @ConfigurationProperties There is a mismatch in names between ServerConfiguration.description and property my.servers[X].server.name=test ...

How to handle form submission in HTML5 + Thymeleaf

html5,forms,spring-boot,thymeleaf

I believe there could be 2 parts to your question and I will try to answer both. First on the form itself how would you get to a child_id to display fields from another object on the form. Since your Person class does not have a Child relationship you would...

How do I limit the amount of times a JMS DefaultMessageListenerContainer will retry a message in ActiveMQ?

spring-boot,activemq

The easiest approach is to use the RedeliveryPolicy available in for ActiveMQ. To use it with spring boot, you could enable it as query params on the Broker URL. tcp://localhost:61616?jms.redeliveryPolicy.maximumRedeliveries=5 You can tweak other features, such as time between redelivery etc with the options described in activemq.apache.org/redelivery-policy.html....

Error while setting targetConnectionFactory in UserCredentialsConnectionFactoryAdapter Spring 4

java,spring,jms,spring-boot,spring-jms

The big difference between your code and the example is in the XML config example that myTargetConnectionFactory is actually a bean managed by Spring. You aren't doing that. You are just creating a new object Spring doesn't know about. The magic happens when setting the targetConnectionFactory of myConnectionFactory. Even though...

how to: Separate a continuous variable by % proportions?

statistics,stata

First, make good use of Stata's help files: e.g., search percentiles returns a list of possible commands. Two commands that will likely be of use are summarize (with the detail option; note that you can use return list afterwards to view/store results [regardless of whether the detail option was specified])...

Spring Boot - How to kill current Spring Security session?

spring,spring-security,spring-boot

If you use basic authentication, the browser stores the authentication until you close it (or exit the incognito mode, if you used it). There is no possibility to delete the session on server side, since the browser would just reauthenticate. If you want to be able to logout, use form...

Precipitation history of a city

statistics,weather

Weather Underground has free historical data. Here's data for Helsinki from January 1, 2015 through June 18, 2015 (for example). You can customize the data range and manually download as a CSV file.

Spring framework unable to start embedded container

java,spring,maven,spring-mvc,spring-boot

When using Spring Boot you should not include the other Spring dependencies directly, but rely on Boot's own dependency management. When using the provided "starters" you can be sure that all needed libraries will be included in a matching version. Instead of including spring-mvc artifact in your pom.xml: <dependency> <groupId>org.springframework</groupId>...

Spring boot war file deploy on Tomcat

tomcat,deployment,spring-boot,war

Just tried this here, and could reproduce the exact same behaviour. As silly as it sounds, most likely you are running your external tomcat under a Java 1.7 JRE (speculation), while having compiled your code against 1.8 (we know this from your pom). Strangely, there is no error, and the...

How to make data repository available in spring boot unit tests?

spring-boot,spring-jpa

Remove the keyword static from your repo field. Static fields aren't autowired.