Sunday, April 18, 2021

java.lang.OutOfMemoryError: Metaspace

So if you were familiar with PermGen then all you need to know as background is that – whatever was in PermGen before Java 8 (name and fields of the class, methods of a class with the bytecode of the methods, constant pool, JIT optimizations etc) – is now located in Metaspace.

As you can see, Metaspace size requirements depend both upon the number of classes loaded as well as the size of such class declarations. So it is easy to see the main cause for the java.lang.OutOfMemoryError: Metaspace is: either too many classes or too big classes being loaded to the Metaspace.

Classloader Leak

A classloader leak happens when an application is redeployed, but there are lingering instances of the previous deployment’s classes left. These lingering instances prevent their Classes from being garbage collected, which, in turn, prevent the classloaders and all the classes held therein from being collected, too. Here’s an example of that situation:

Apparently, the application starts a thread that cleans up connections. As noble of a goal as it is, the application does not stop the thread on un-deploy, so it keeps hold of the classloader. Cleanup threads and Timer threads are by far the most common reason for the leaks. A simple way of fixing this issue would be to add a shutdown hook by implementing a ServletContextListener:


public class CleanupCleanup implements ServletContextListener {
  @Override
  public void contextDestroyed(ServletContextEvent sce) {
    // Stop the cleanup thread
  }

  //...
}

Java + HTTPS: Unable to Find Valid Certification Path to Requested Target

https://myshittycode.com/2015/12/17/java-https-unable-to-find-valid-certification-path-to-requested-target-2/

https://www.baeldung.com/java-import-cer-certificate-into-keystore

https://stackoverflow.com/questions/43188589/what-is-the-difference-between-keytool-commands-import-and-importcert/43188724


From this documentation keytool - Key and Certificate Management Tool, the Changes section at the end of the page says :

Renamed commands:

-import, renamed to -importcert


The keytool has many options but the one we're interested in is importcert which is as straightforward as its name. Since there are usually different entries inside a KeyStore, we'll have to use the alias argument to assign it a unique name:

> keytool -importcert -alias baeldung_public_cert -file baeldung.cer -keystore sample_keystore
> Enter keystore password:
...
> Trust this certificate? [no]:  y
> Certificate was added to keystore

Keystore-Explorer

https://keystore-explorer.org/downloads.html

Format Disk in Linux

 snap-9df717f4 US Census 1980

-------------------------------

lsblk

df -h

cat /etc/fstab

fdisk -l


https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ebs-using-volumes.html

--------------------------------

mount 


available/in-use - Status of Volumes



If Snapshot is Encrypted, Volume is also Encrypted

If Snapshot is not-Encrypted, Volume is also unEncrypted


Shred Command


https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ebs-using-volumes.html


shred -u filename

shred overrides a File's Value and then removes it - so Restore from Recycle Bin does not happen


[ec2-user ~]$ sudo file -s /dev/xvdf

/dev/xvdf: data


Create a file system on the volume - [Conditional Step]

sudo mkfs -t xfs /dev/xvdf


Javabrains POC - Microservices - Part 2 [ Netflix OSS]

https://jsonplaceholder.typicode.com/posts/


https://spring.io/projects/spring-cloud-netflix

Spring Cloud Azure
Spring Cloud for Amazon Web Services
Spring Cloud GCP
Spring Cloud Netflix [Ribbon, Feign, Eureka]
Spring Cloud Kubernetes
Spring Cloud Gateway
Spring Cloud Circuit Breaker
Spring Cloud Config
Spring Cloud OpenFeign
Spring Cloud Consul
Spring Cloud Vault
Spring Cloud Zookeeper

Spring Cloud Netflix OSS 
Feign - Declarative HTTP Client
Eureka - Service Register and Discovery
Ribbon - Client Side Load Balancing
Hytrix - Fault Tolerance Library

Spring Cloud Netflix features:

  • Service Discovery: Eureka instances can be registered and clients can discover the instances using Spring-managed beans

  • Service Discovery: an embedded Eureka server can be created with declarative Java configuration

  • Circuit Breaker: Hystrix clients can be built with a simple annotation-driven method decorator

  • Circuit Breaker: embedded Hystrix dashboard with declarative Java configuration

  • Declarative REST Client: Feign creates a dynamic implementation of an interface decorated with JAX-RS or Spring MVC annotations

  • Client Side Load Balancer: Ribbon

  • External Configuration: a bridge from the Spring Environment to Archaius (enables native configuration of Netflix components using Spring Boot conventions)

  • Router and Filter: automatic registration of Zuul filters, and a simple convention over configuration approach to reverse proxy creation


-----------------------------------------------------------------------------------------------------------


Release TrainBoot Version

2020.0.x aka Ilford

2.4.x

Hoxton

2.2.x, 2.3.x (Starting with SR5)

Greenwich

2.1.x

Finchley

2.0.x

Edgware

1.5.x

Dalston

1.5.x


<dependency>
   <groupId>org.springframework.cloud</groupId>
   <artifactId>spring-cloud-starter-netflix-ribbon</artifactId>
</dependency>

This is happening because http://microservice_provider_user/ is not a legal host name.

Don't use Underscore for Hostnames


Using Ribbon with Eureka
Use Ribbon Without Eureka
----------------------------------------------------------------------------------------------------------------
Feign

----------------------------------------------------------------------------------------------------------------


----------------------------------------------------------------------------------------------------------------


Adobe XD - UI, UX , Product- Wireframe, Mockup, Prototype






Product Designer >  UX  Designer > UI  Designer

UI Designer - means Designing wireframes, UI (Fonts, Icons, Color) and handing it to developers

UX Designer - UX means Designing wireframes, UI (Fonts, Icons, Color) and Navigation Pathways and Actually Testing them from End user pov

Product Designer - Highlevel View, Budgets, Timelines, Client Approval + UI/UX role



Wireframes, Mockup, Prototype
Wireframes : 1 Color, 1 Font Size, Monochromatic - Usually Black and White - Skeleton Design - Sketches etc [https://www.wireframe.cc]
Mockup : All Screens with Higher Fidelity - Real colors, Real Fonts, Icons , Images etc. but no functionality, You basically cannot click anywhere
Prototype : All Things in a mockup + Functionality (Clickable Links navigating between screens)

Fidelity
Fidelity means level of detail - Color, Fonts, Icon, Logo, Images, Sizes in design

https://www.w3schools.com/tags/tag_canvas.asp
The <canvas> tag is used to draw graphics, on the fly, via scripting (usually JavaScript).


Monday, April 12, 2021

Spring Cloud, Netflix, Microservices - V V IMP

https://cloud.spring.io/spring-cloud-netflix/multi/multi_spring-cloud-ribbon.html


https://cloud.spring.io/spring-cloud-netflix/1.0.x/

https://stackoverflow.com/questions/39587317/difference-between-ribbonclient-and-loadbalanced

https://www.baeldung.com/spring-cloud-rest-client-with-netflix-ribbon

https://howtodoinjava.com/spring-cloud/spring-boot-ribbon-eureka/#ribbon

https://dzone.com/articles/using-new-spring-cloud-load-balancer-in-microservi

@EnableEurekaClient

@EnableDiscoveryClient


@RibbonClient(name="")

https://stackoverflow.com/questions/31976236/whats-the-difference-between-enableeurekaclient-and-enablediscoveryclient

https://piotrminkowski.com/2020/05/13/a-deep-dive-into-spring-cloud-load-balancer/

A New Era of Spring Cloud. While almost all of Spring Cloud Netflix components will be removed in the next release, it seems that the biggest change is a replacement of Ribbon client into Spring Cloud Load Balancer.

---------------------------------------------------------------------------------------------------

https://www.baeldung.com/spring-component-scanning

@ComponentScan Without Arguments

we use the @ComponentScan annotation along with @Configuration annotation to specify the packages that we want to be scanned. 
@ComponentScan without arguments tells Spring to scan the current package and all of its sub-packages.

The trick with Spring Boot is that many things happen implicitly. 
We use the @SpringBootApplication annotation, but it's just a combination of three annotations:
Using @ComponentScan in a Spring Boot Application.

@Configuration
@EnableAutoConfiguration
@ComponentScan
@ComponentScan With Arguments
@ComponentScan(basePackages = "com.baeldung.componentscan.springapp.animals")

spring.application.name=user-service
server.port=8888

1
2
3
4
5
6
spring:
  application:
    name: user

server:
  port: 8888






Azure - Pipeline - Add Approver for Stage

https://learn.microsoft.com/en-us/azure/devops/pipelines/process/approvals?view=azure-devops&tabs=check-pass