Sunday, February 21, 2021

HTTP API - EAP7.3 - Deployment using HTTP Curl

https://access.redhat.com/documentation/en-us/red_hat_jboss_enterprise_application_platform/7.0/html/configuration_guide/deploying_applications#deploying_apps_using_http_api



7.5.1. Deploy an Application to a Standalone Server Using the HTTP API

By default, the HTTP API is accessible at http://HOST:PORT/management, for example, http://localhost:9990/management.
Deploy an Application
$ curl --digest -L -D - http://HOST:PORT/management --header "Content-Type: application/json" -u USER:PASSWORD -d '{"operation" : "composite", "address" : [], "steps" : [{"operation" : "add", "address" : {"deployment" : "test-application.war"}, "content" : [{"url" : "file:/path/to/test-application.war"}]},{"operation" : "deploy", "address" : {"deployment" : "test-application.war"}}],"json.pretty":1}'
Undeploy an Application
$ curl --digest -L -D - http://HOST:PORT/management --header "Content-Type: application/json" -u USER:PASSWORD -d '{"operation" : "composite", "address" : [], "steps" : [{"operation" : "undeploy", "address" : {"deployment" : "test-application.war"}},{"operation" : "remove", "address" : {"deployment" : "test-application.war"}}],"json.pretty":1}'

Saturday, February 20, 2021

Difference between NAT, Host-Only, Bridge - Networking Adapters - NIC


NIC /Network Adapter - Network Interface Card

A device can have many IP Addresses or Network Interface Cards or Network Adapters

A computer can be part of many networks

https://superuser.com/questions/227505/what-is-the-difference-between-nat-bridged-host-only-networking

  • Host-Only: The VM will be assigned one IP, but it's only accessible by the box VM is running on. No other computers can access it.

  • NAT: Just like your home network with a wireless router, the VM will be assigned in a separate subnet, like 192.168.6.1 is your host computer, and VM is 192.168.6.3, then your VM can access outside network like your host, but no outside access to your VM directly, it's protected.

  • Bridged: Your VM will be in the same network as your host, if your host IP is 172.16.120.45 then your VM will be like 172.16.120.50. It can be accessed by all computers in your host network.

How to install Ubuntu and Docker on VirtualBox

https://medium.com/nycdev/how-to-ssh-from-a-host-to-a-guest-vm-on-your-local-machine-6cb4c91acc2e

https://www.freecodecamp.org/news/how-to-install-ubuntu-with-oracle-virtualbox/

https://www.digitalocean.com/community/tutorials/how-to-install-and-use-docker-on-ubuntu-18-04

Tuesday, February 2, 2021

Address in Use ? Port Open ? linux

https://mkyong.com/linux/linux-which-application-is-using-port-8080/

lsof -i :8080
 netstat -nlp | grep 8080
ps -ef | grep 10165




1. lsof + ps command
1.1 Bring up the terminal, type lsof -i :8080
$ lsof -i :8080

COMMAND   PID   USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
java    10165 mkyong   52u  IPv6 191544      0t0  TCP *:http-alt (LISTEN)
Note
If multiple result, try lsof -i :8080 | grep LISTEN
1.2 PID 10165 is using port 8080, type ps -ef | grep 10165 to find out the application details.
$ ps -ef | grep 10165

mkyong   10165  4364  1 11:58 ?        00:00:20 /opt/jdk/jdk1.8.0_66/jre/bin/java
//...
-Djava.endorsed.dirs=/home/mkyong/software/apache-tomcat-8.0.30/endorsed
-classpath /home/mkyong/software/apache-tomcat-8.0.30/bin/bootstrap.jar:
/home/mkyong/software/apache-tomcat-8.0.30/bin/tomcat-juli.jar
-Dcatalina.base=/home/mkyong/.IntelliJIdea15/system/tomcat/Unnamed_hc_2
-Dcatalina.home=/home/mkyong/software/apache-tomcat-8.0.30
-Djava.io.tmpdir=/home/mkyong/software/apache-tomcat-8.0.30
/temp org.apache.catalina.startup.Bootstrap start
Answer : IntelliJ IDEA + Tomcat 8 is using the port 8080.
Trendsetters Feed
Vala Afshar
@ValaAfshar
2d
View image
Nearly all men can stand adversity, but if you want to test a man's character, give him power. —Abraham Lincoln https://t.co/HKkQ...
5h
View image


2. netstat + ps command

Just different command to do the same thing.Type netstat -nlp | grep 8080 to get the PID and ps it.
$ netstat -nlp | grep 8080

(Not all processes could be identified, non-owned process info
 will not be shown, you would have to be root to see it all.)
tcp6       0      0 :::8080                 :::*                    LISTEN      10165/java

$ ps -ef | grep 10165

mkyong   10165  4364  1 11:58 ?        00:00:20 /opt/jdk/jdk1.8.0_66/jre/bin/java
//...

Best Website which actually teaches Linux - Hands On - Learn Linux

https://linuxjourney.com/


https://www.linuxtrainingacademy.com/   Jason Cannon

User specific Profiles in Linux

 All UNIX users can override the system umask defaults in their /etc/profile file

~/.profile (Korn / Bourne shell) 
~/.cshrc file (C shells), 
~/.bash_profile (Bash shell) 
~/.login file (defines the user’s environment at login).


  • 4 Read
  • 2 Write
  • 1 Execute

Monday, February 1, 2021

Streams, Lamdas, Method References- Examples

https://www.baeldung.com/java-stream-filter-lambda
https://www.baeldung.com/java-maps-streams
https://www.baeldung.com/java-method-references

List<String> isbnCodes = books.entrySet().stream()
  .filter(e -> e.getValue().startsWith("Effective Java"))
  .map(Map.Entry::getKey)
  .collect(Collectors.toList());



replaceSpecialCharUtil.convertResourceBundleToMap(junkCharResource).entrySet().stream()
				.forEach(entry -> logger.info(entry.getKey() + " : " + entry.getValue()));

junkCharResource.getKeys().asIterator().forEachRemaining(key -> logger.info(key));

Set<String> keySet = messageSourceProperties.keySet().stream()
				.map(Object::toString).collect(Collectors.toSet());



We can achieve this by leveraging a simple lambda expression calling the StringUtils.capitalize() method directly:

messages.forEach(word -> StringUtils.capitalize(word));

Or, we can use a method reference to simply refer to the capitalize static method:

messages.forEach(StringUtils::capitalize);

Notice that method references always utilize the :: operator.

Spring: contextConfigLocation context-param and init-param in web.xml

https://stackoverflow.com/questions/15818047/spring-namespace-vs-contextconfiglocation-init-parameters-in-web-xml

https://stackoverflow.com/questions/27539610/order-of-loading-contextconfiglocation-in-web-xml-of-spring-servlet-project

https://howtodoinjava.com/spring-mvc/contextloaderlistener-vs-dispatcherservlet/


DispatcherServlet – Child application contexts

DispatcherServlet is essentially a Servlet (it extends HttpServlet) whose primary purpose is to handle incoming web requests matching the configured URL pattern. It take an incoming URI and find the right combination of controller and view. So it is the front controller.

When you define a DispatcherServlet in spring configuration, you provide an XML file with entries of controller classes, views mappings etc. using contextConfigLocation attribute.

web.xml
<servlet>
    <servlet-name>employee-services</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <init-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>classpath:employee-services-servlet.xml</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
</servlet>



ContextLoaderListener – Root application context

ContextLoaderListener creates the root application context and will be shared with child contexts created by all DispatcherServlet contexts. You can have only one entry of this in web.xml.

web.xml
<listener>
  <listener-class>
    org.springframework.web.context.ContextLoaderListener
  </listener-class>
</listener>
  
<context-param>
  <param-name>contextConfigLocation</param-name>
  <param-value>/WEB-INF/spring/applicationContext.xml</param-value>
</context-param>

The context of ContextLoaderListener contains beans that globally visible, like services, repositories, infrastructure beans, etc.


Azure - Pipeline - Add Approver for Stage

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