ui final Flashcards

1
Q

What is the use of the ‘os’ module in Node.js?

A

deals with operating systems

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is the purpose of the “path” module in Node.js?

A

handles file paths

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Which command is used to install a package globally in Node.js using npm?

A

Apply -g

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How do you handle file operations in Node.js?

A

“fs”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Which one is a key feature of Node.js?

A

Uses an event-driven, non-blocking architecture that works on single
threaded model and processes events using callbacks.
* For example, HTTP calls made to server from Node.js code is non-blocking,
asynchronous, does not wait for the response, and handles the response when it
comes, using a callback model.
* This makes Node.js extremely effective and scalable for managing concurrent
connections and processes.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Which of the following method of fs module is used to read a file in Node.js?

A

fs.readFile()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Which one of the following command will display all globally installed packages in npm?

A

npm ls –depth=0 -global

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What does the “require” function in Node.js do?

A

a built-in function to include external modules
that exist in separate files

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

How do you append data to a file in Node.js?

A

fs.appendFile()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

In the context of Node.js, what does the term “REPL” mean?

A

Read Evaluate Print Loop

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

How is callback function used in Node.js?

A

A callback is a function that is invoked after the asynchronous
operation is finished and is supplied as an input to another function.
* Asynchronous operations in Node.js, such as reading files, making
network requests, or querying databases, are non-blocking,
– This means the code doesn’t wait for the operation to complete before moving
on to the next line.
– Instead, it initiates the operation and continues executing the remaining code.
– When the asynchronous operation is complete, a callback function is called
to handle the result or any errors.
In Node.js, callbacks usually follow an error-first convention, where the first parameter of the callback
function is reserved for an error object.
– If no error occurred, this parameter will be null or undefined.
– If an error occurs, the subsequent parameters may hold additional data.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Which built-in module should you use to make a HTTP request in Node.js?

A

“http”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

core modules of node.js

A

“fs”, which handles file system operations
* “http”, which creates HTTP servers and clients
* “path”, which handles file paths
* “os”, which deals with operating systems

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

How do you copy a file in Node.js?

A

fs.copyFile()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

How do you read a file in Node.js?

A

fs.readFile()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

How do you write a file in Node.js?

A

fs.writeFile()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

Node Package Manager

A

npm is a package manager for node.js and is comprised of
three components
– Website - to discover packages (https://www.npmjs.com/)
– Command Line Interface (CLI) – to run commands from a terminal
* this is how most developers interact with npm.
* npm gets installed automatically when you install node.js
* npm –v //tells version of npm installed
– Registry - a large public database of JavaScript libraries and the
meta-information surrounding it.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

External Modules

A

External modules produced by the community can be installed
and utilized in Node.js applications using package managers like
npm
* These modules are available for installation with a single
command and are kept in the npm registry.
* Examples of external modules include:
* Axios for sending HTTP requests,
* Moment.js for handling dates and times, and
* Mongoose for interacting with MongoDB databases

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

even-driven architecture of Node.js

A

Node.js is based on a non-blocking, event-driven architecture,
* as a result, it is extremely effective at managing concurrent connections and I/O activities.
* Node.js uses a “single-threaded, event-driven” architecture, which eliminates the
need to create new threads for every connection
* and instead allows a single event loop to manage multiple concurrent connections.
* An event loop is used by Node.js to control events and callbacks.
* The callbacks are triggered by the event loop, which continuously scans for events like incoming
requests or finished I/O operations.
* Node.js handles asynchronous actions by using callbacks as a common pattern.
* All I/O operations in Node.js are carried out asynchronously via callbacks,
* Enabling the program to carry out other tasks without waiting for the I/O activity to finish.
* Examples of this include reading from a file, sending an HTTP request, or querying a database.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

execute the content of a JavaScript file (module) from inside
another JavaScript file, include the 2nd file in the first file

A

require(/relative path of the 2nd file) statement

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

Node.js built-in functions: exports

A

Exports allows you to call functions that are defined in one module
(calculator.js file) from another module (hello.js file) using module.exports

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

What does the @SpringBootApplication annotation do in Spring Boot?

A

annotation is used to bootstrap a Spring Boot
application. It is a combination of @Configuration, @EnableAutoConfiguration,
and @ComponentScan.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

In Spring Boot, what is the purpose of the @ResponseBody annotation?

A

used to indicate that the return value of a controller method should be
serialized and sent as the response body. It is typically used with the @RequestMapping annotation.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

In Spring Boot, what is the purpose of the @PathVariableannotation?

A

used to extract a variable from the URI of a request. It is typically used
with the @RequestMapping annotation.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
@Autowired
used to inject dependencies into a Spring Bean. It can be used to inject dependencies on other beans, properties, and constructors.
26
Which of the following is a Spring module that allows you to work with relational database management systems (RDBMS) using Java Database Connectivity (JDBC)?
Spring JDBC module
27
@Service
It is typically used to define a business logic layer in a Spring application.
28
@RestController
used to create a RESTful web service. It is a specialized version of the @Controller annotation that adds support for the HTTP methods GET, POST, PUT, DELETE, and others.
29
@RequestBody:
This annotation is used to extract the body of a request. It is typically used with the @RequestMapping annotation.
30
@ExceptionHandler
This annotation is used to handle exceptions thrown by a controller method. It can be used to return a specific HTTP response code or error message.
31
In Spring Boot, which of the following is used to bind a method parameter to the value of an HTTP header?
@RequestHeader
32
In Spring Boot, which of the following is a core module in Spring Framework?
Core Container * DataAccess/Integration * Web * AOP/Instrumentation/Messaging * Test
33
annotation is used to declare a JPA repository in Spring Data JPA?
@Repository
34
What is the purpose of the Spring Boot @Repository annotation?
This annotation is used to mark a class as a Spring Data repository. It tells Spring to generate a repository implementation for the interface.
35
@Column
This annotation is used to specify the mapping between an entity field and a column in a database table. It is typically used with the @Entity annotation.
36
@GeneratedValue
: This annotation is used to specify how the primary key of an entity is generated.
37
@Id
This annotation is used to specify the primary key of an entity. It is typically used with the @Entity annotation.
38
@Table:
This annotation is used to specify the name of the table that an entity is mapped to. It is typically used with the @Entity annotation.
39
@Entity
This annotation is used to define an entity class. It is typically used to represent a table in a database.
40
What does the Spring Framework provide to enterprise Java developers?
: Spring provides enterprise-level features like transaction management, security, and data access,
41
dependency management and build automation tool used in Spring Boot projects?
maven and gradle
42
What does the @EnableJpaRepositories annotation do in Spring Boot?
used to enable Spring Data JPA repositories
43
In a Spring Boot application, which of the following is the default embedded server?
Apache Tomcat.
44
What is Spring Data JPA primarily used for?
primarily used for simplifying the development of data access layers for Java applications that use the Java Persistence API (JPA) to interact with relational databases.
45
What does the Spring Boot @DeleteMapping annotation do?
used to map HTTP DELETE requests onto specific handler methods in your controller classes.
46
In Spring Boot, which of the following specifies a method parameter should be bound to the body of the web request?
@RequestBody
47
In Spring Boot, which of the following is used to handle exceptions?
@ExceptionHandler
48
What does the @Component annotation do in Spring Boot?
used to mark a class as a Spring Bean. It tells Spring to manage the lifecycle of the bean and to inject its dependencies.
49
What is the purpose of the Spring Framework's Inversion of Control (IoC) container?
A programming principle in which the control flow of a program is inverted, with objects receiving dependencies from external sources (like the Spring Framework) rather than (programmers) creating them themselves (in the program) The Spring IoC container is responsible for instantiating, configuring and managing the lifecycle of the objects (beans). * It simplifies the development of complex applications by reducing the amount of boilerplate code required and promoting modularity and flexibility.
50
In Spring Boot, which of the following allows you to setup the application without the need of XML?
@Configuration and @Bean annotations.
51
What does the @RequestMapping annotation do in Spring Boot?
This annotation is used to map HTTP requests to controller methods. It is used to specify the URI of the request and the HTTP method that the method should handle.
52
What does the Spring Boot @PutMapping annotation do?
used to map HTTP PUT requests onto specific handler methods
53
In Spring Boot, which of the following specifies a method, constructor argument, or field should be automatically populated with a value by Spring's dependency injection facilities?
@Autowired.
54
Dependency Injection
A design pattern that allows objects to receive their dependencies from external sources rather than creating them themselves.
55
Core Container
This contains the fundamental modules that are the cornerstone of the Spring framework. * Core (spring-core) is the core of the framework that power features such as Inversion of Control and dependency injection. * Beans (spring-beans) provides Beanfactory, which is a sophisticated implementation of the factory pattern. * Context (spring-context) builds on Core and Beans and provides a medium to access defined objects. ApplicationContext interface is the core part of the Context module. * SpEL (spring-expression) enables users to use the Spring Expression Language to query and manipulate the object graph at runtime.
56
Data Access/Integration
This includes the modules that are used to handle data access and transaction processing in an application. * JDBC (spring-jdbc) provides a JDBC abstraction layer that eliminates the need to separate JDBC coding when dealing with databases. * ORM (spring-orm) are integration layers for popular object-relational mapping API such as JPA, JDO Hibernate. * OXM (spring-oxm) is the abstraction layer that supports Object/XML mapping implementations like JAXB, XStream. * JMS (spring-jms) is the Java Messaging Service module that creates and consumes messages that directly integrate with the Spring messaging module. * Transaction (spring-tx) offers programmatic and declarative transaction management for classes that include special interfaces and POJOs.
57
Web
The Web layer relates to modules that power web-based functions in Spring. * WebSocket (spring-websocket) powers the web socket-based communication for clients and servers. * Servlet (spring-webmvc) is the Spring WebMVC module that contains the MVC and REST implementations. * Web (spring-web) provides all the basic web-oriented features and contains an HTTP client and web-related parts of the Spring remoting. * Portlet (spring-webmvc-portlet) provides the MVC implementation to be used in a portlet environment.
58
Other modules
AOP (spring -aop) provides an aspect -oriented programming implementation. AOP aims to provide more modularity to the cross -cutting concerns, which are functions that span across the application, such as Logging, Caching, Transaction management, Authentication . * Aspects (spring -aspects) enables direct integration with the AspectJ programming extension by the eclipse foundation. * Instrumentation (spring -instrument) is the class instrumentation support and class loader implementations for application servers. * Messaging (spring -messaging) provides a robust platform to manage messaging in applications. * Spring Messaging module includes key abstractions from the Spring Integration project and a set of annotations for mapping messages to methods. * Test (spring -test) is the Spring test module that supports unit and integration testing with JUnit and TestNG.
59
Main Features of Spring Boot
Autoconfiguration automatically configures most of the application components Embedded Server includes an embedded Tomcat, Jetty or Undertow server Dependency Management manages the dependencies and their versions Actuator provides information about the application health, metrics, and other details Spring Data provides support for database integration Spring Security provides security features such as authentication and authorization
60
What is the purpose of Hibernate in relation to JPA?
Hibernate is an open-source, lightweight, ORM tool. * Hibernate implements JPA and further extends it with additional features.
61
What does JPA stand for in the context of Java development?
Java Persistence API
62
In the context of JPA, what is an Entity?
Entities are persistence objects that are stored as records in database tables. An entity represents a table in a relational database, and each entity instance corresponds to a row in the table.
63
What does the @Entity annotation indicate in JPA?
ndicating that it is a JPA entity
64
How can CRUD operations be implemented using JPA and Hibernate?
using entitymanager
65
Which of the following best describes Object-Relational Mapping (ORM)?
JPA provides a way to map Java classes to database tables and Java data types to SQL data types. This is defined through annotations or XML, or a combination of both.
66
What does the @Table annotation do in JPA?
used to specify the details of the table that will be used to persist an entity in the database
67
What is the difference between @Embeddable and @Entity in JPA?
@Entity: Marks a class as a persistent entity, representing a table in the database. @Embeddable: Defines a class whose instances are stored as part of an owning entity, sharing its identity
68
In JPA, what is a persistence context?
a set of entities such that for any persistent identity there is a unique entity instance
69
a valid way to create an instance of EntityManager?
EntityManagerFactory emf = Persistence.createEntityManagerFactory("myPersistenceUnit"); // Create EntityManager EntityManager em = emf.createEntityManager(); or @PersistenceContext private EntityManager entityManager; public void performOperation() { // Use EntityManager entityManager.getTransaction().begin(); // Your CRUD operations here entityManager.getTransaction().commit(); }
70
What does the @Column annotation do in JPA?
Specify the column mapping
71
What does the @ElementCollection annotation do in JPA?
used to map a collection of basic or embeddable objects to a separate table in the database.
72
Which of the following is a valid role of the persistence context in JPA?
Managing Entity Lifecycle,First-Level Cache
73
what is the primary purpose of the Java Persistence API?
to provide a standardized way for Java developers to manage the persistence of object data by mapping Java objects to relational database tables,
74
responsibility of a repository in Spring Data JPA?
JPA Repository manages the persistent data in a Spring Boot Application.
75
What does the term "Lazy Loading" refer to in the context of JPA?
to defer the loading of data until it is actually needed
76
What is the role of the @GeneratedValue annotation in JPA?
This annotation is used to specify how the primary key of an entity is generated. It is typically used with the @Id annotation.
77
What is the purpose of the @Transient annotation in JPA?
Fields that should not be persisted
78
What is the purpose of the persistence.xml file in a JPA application?
used to configure a given JPA Persistence Unit
79
What is the purpose of the @OrderBy annotation in JPA?
Specifies the ordering of the elements of a collection valued association or element collection at the point when the association or collection is retrieved.
80
What is the purpose of the @SecondaryTable annotation in JPA?
Specifies a secondary table for the annotated entity class
81
In JPA, which of the following best describes a persistent field?
Every non-static non-final entity field is persistent by default unless explicitly specified otherwise. persist:storing data to be retrieved and used even after the application that generated it has stopped running.
82
In the context of JPA, when would you use CascadeType.ALL on a relationship?
the persistence will propagate (cascade) all EntityManager operations (PERSIST, REMOVE, REFRESH, MERGE, DETACH) to the relating entities.
83
What does the EntityManager interface in JPA handle?
the primary way for interacting with the persistence context.
84
What is the difference between the persist() and merge() methods in JPA?
Persist takes an entity instance, adds it to the context and makes that instance managed (i.e. future updates to the entity will be tracked). Merge returns the managed instance that the state was merged with.
85
In JAX-RS, what is the purpose of @PathParam annotation?
used to bind template parameters to a resource class field.
86
What does SOAP stand for in the context of web services?
(Simple Object Access Protocol
87
In JAX-RS, what is the purpose of the @Path annotation?
to define a URI matching pattern for incoming HTTP requests
88
What is the primary data format used in RESTful Web services?
json
89
HTTP methods
GET to retrieve a resource * POST to create a new resource * PUT or PATCH to update an existing resource * DELETE to remove a resource
90
What does REST stand for?
: Representational State Transfer
91
What is the main purpose of the @XmlRootElement annotation in JAX-RS?
allowing a conversion between Java and XML
92
How can you specify the consumed and produced media type of a resource in JAX-RS?
@Consumes and @Produces annotations to declare the media types that are acceptable for a resource method to read and write.
93
Which of these annotations is used in Spring Boot to map a specific HTTP method to a Java method?
GET to retrieve a resource * POST to create a new resource * PUT or PATCH to update an existing resource * DELETE to remove a resource
94
How does Jersey help in creating RESTful Web Services with Spring Boot?
a reference implementation of JAX-RS specification * Implements supports for the annotations defined in JAX-RS spec * Jersey based REST API application is a standard Servlet application * It has jersey jars in the class path * Web.xml contains a jersey servlet class ServletContainer, which is mapped to a URL pattern to handle all REST API requests * Jersey servlet looks at your code (i.e., java class) to determine the method to delegate the HTTP requests to be handled * This means that http methods need to be mapped to java method
95
In the context of RESTful Web services, what does "uniform interface" mean?
The REST architecture establishes a set of well-defined methods, headers, media types, etc. that provide a uniform interface between clients and servers.
96
Which of the following is not one of the two prevailing styles of Web services?
RESTful Web Services and SOAP
97
What does it mean if a Web service is "stateful"?
allow users to store, record, and return to already established information and processes over the internet
98
What does the term idempotent mean in the context of HTTP methods?
making multiple identical PUT requests will have the same effect as making a single request
99
In Spring Boot, what is the purpose of the SpringApplication.run() method?
bootstraps a spring application as a stand-alone application from the main method.
100
In RESTful Web services, what does statelessness mean?
Each HTTP request should carry enough information itself to process the request. The server should not store anything about the latest HTTP request the client made; the server does not maintain any context between two requests
101
In the context of RESTful Web services, what does CRUD stand for?
Create, Retrieve, Update, Delete
102
How can you specify the HTTP method of a resource method in JAX-RS?
@GET, @POST, @PUT, @DELETE, and @HEAD. * @Produces, @Consumes to specify data format to be sent out or received
103
In Spring Boot, how do you specify that a method should respond to HTTP GET requests?
@GET
104
In JAX-RS, what is the purpose of the @Consumes annotation?
o specify which MIME media types of representations a resource can accept, or consume, from the clien
105
In the context of RESTful Web services, what is a resource?
a specific piece of data or object that can be accessed and manipulated through a unique Uniform Resource Identifier (URI)
106
Key principles of RESTful web services
Stateless: Each HTTP request should carry enough information itself to process the request. The server should not store anything about the latest HTTP request the client made; the server does not maintain any context between two requests. * Client-Server: This principle establishes that the client and the server should be able to evolve separately without any dependency on each other. A client should know only resource URIs, and a server should know the context on which the request came for. * Cacheable: Caching in RESTful web services is similar to caching in web browsers. If the server response is defined as cacheable, then the client cache can reuse the response data for equivalent responses in the future. * Uniform Interface: The REST architecture establishes a set of well-defined methods, headers, media types, etc. that provide a uniform interface between clients and servers. * Multiple Representation of Data - Supports multiple representation of data for data exchange: XML, JSON, XHTML, plain text, PDF, JPEG, and others
107
Parameter annotations
There are annotations to extract information from a request: * @PathParam, @QueryParam, @FormParam, @HeaderParam, and @CookieParam.
108
Application class and @ApplicationPath
used to specify the base path for all the RESTful resources in the packaged archive
109
What is the responsibility of a Kafka broker in a Kafka cluster?
storing and managing data streams
110
How can a Kafka cluster be made fault-tolerant?
replicated across brokers
111
In Apache Kafka, what is a consumer group?
one or more consumers that work together to consume a topic and parallelize the read. – The group ensures that each partition is only consumed by one member. – Consumers within a consumer group do not read data from the same partition but can receive data from one or more partitions.
112
In Apache Kafka, how is data written to a partition?
Key-Based Partitioning Round-Robin Partitioning Custom Partitioning (Using a Custom Partitioning Strategy) Default Partition (When No Key is Provided)
113
What is the responsibility of a JMS producer in a JMS Publish/Subscribe messaging model?
A JMS client that creates and sends messages.
114
Java Message Service
Java API that allows applications to create, send, receive, and read messages.
115
JMS Provider:
A messaging system that implements the JMS interfaces. It provides administrative and control features.
116
JMS Client
An application or process that produces and/or receives messages.
117
JMS Consumer:
A JMS client that receives messages.
118
JMS Message:
An object that contains the data being transferred between JMS clients.
119
JMS Queue
A staging area that contains messages that have been sent and are waiting to be read (note that queues retain all messages sent to them until the messages are consumed or until the messages expire).
120
JMS Topic
A distribution mechanism for publishing messages that are delivered to multiple subscribers.
121
jms Point-to-Point (PTP) model
In the PTP model, a producer sends messages to a queue, and a consumer reads these messages from the queue. Here, the consumer acknowledges the message upon receipt. * In this model, messages are not published to all consumers. Instead, only a single consumer will get the message and process it
122
JMS Publish/Subscribe (pub/sub) model:
In the pub/sub model, a producer sends messages to a topic, and all subscribers to that topic receive the messages. * If a new subscriber is added, they will only receive messages that were published after they subscribed; they will not receive messages that were published before their subscription.
123
Kafka Producers
Producers create new messages. – Producers are applications that get the data into the Kafka * Kafka producers are the publishers responsible for writing records to topics. – Typically, this means writing a program using the KafkaProducer API. – Producers typically send events or records to a given topic in Kafka to a certain partition – Producers publish log to topics in monotonically increasing order
124
Message Key
determines which partition your message should be written to. – The key identifies the subject of the message, or a property of the message. * All message with same key go to the same partition. * Messages without the (optional) key are sent to partitions in round-robin fashion
125
In a Kafka cluster, how can high availability be achieved?
Partitions are the way that Kafka provides redundancy and scalability. * Each partition can be hosted on a different server, – which means that a single topic can be scaled horizontally across multiple servers to provide performance far beyond the ability of a single server. * Partitions can be replicated, so that different servers will store a copy of the same partition in case one server fails.
126
In the context of Apache Kafka, what is a partition?
the way that Kafka provides redundancy and scalability. a division in a topic
127
In Apache Kafka, what happens when a broker fails?
the partitions it was leading become temporarily unavailable while the Kafka controller elects a new leader from among the follower replicas, if no replicas all data is lost
128
In Kafka, how is data distributed across multiple brokers?
By dividing topics into partitions
129
What is Apache ActiveMQ?
opensource message broker written in Java together with a full Java Message Service (JMS) client.
130
In JMS, what is the purpose of the MessageListener interface?
used to receive asynchronously delivered messages
131
Which JMS messaging model is inherently asynchronous?
Publish/Subscribe
132
In the context of Kafka, what is a message record?
the basic unit of data, essentially a single piece of information that is stored and transmitted within a topic, consisting of a key, a value, and optional metadata (headers), essentially representing an "event" that occurred in a system
133
In a Kafka cluster, how can scalability be achieved?
topics partitions that are distributed across brokers for distributed processing and for performance and scalability
134
What does the KafkaProducer API do?
allows applications to publish (write) streams of data, called messages, to one or more Kafka topics
135
In a JMS topic, what happens if a message is published while a subscriber is inactive?
For non-durable subscribers, messages sent while inactive are lost. For durable subscribers, the messages are stored and delivered when the subscriber reconnects.
136
In Kafka, what is the purpose of the offset?
the offset is a numerical value that tracks the order of messages in a partition
137
What is the responsibility of a JMS producer in a JMS Point-to-Point messaging model?
a producer sends messages to a queue, and a consumer reads these messages from the queue
138
What is a Kafka topic partition?
a committed append-only log –terms partitions and logs are used interchangeably. a logical division within a Kafka topic, essentially a subset of messages within a topic that acts as a separate log
139
In a JMS topic, what happens if a message is published while a non-durable subscriber is inactive?
messages sent while inactive are lost.
140
In Kafka, how is data read from a partition?
by a consumer within a consumer group
141
In a Kafka cluster, what is a leader replica?
the designated copy of a partition within a topic that is responsible for handling all read and write operations for that partition
142
What does the KafkaConsumer API do?
enables developers to create their own consumers to read data from Kafka topic
143
In Apache Kafka, what is a topic?
provides a channel to publish and subscribe streams of events – A logical representation of data or logical grouping of like messages, e.g., weather-data, book-orders, credit-card-transactions, a twitter feed – Messages are sent to and received from a topic – The closest analogies for a topic are a database table or a folder in a filesystem.
144
In a Kafka cluster, what is a follower replica?
a copy of a partition's data stored on a different broker, which passively replicates the data from the designated "leader" replica
145
In a JMS topic, what happens if a message is published while a durable subscriber is inactive?
the messages are stored and delivered when the subscriber reconnects.
146
In a Kafka cluster, what is an in-sync replica (ISR)?
has the same number of messages as the leader.
147
out of sync replica:
A replica is out of sync if it hasn’t requested a message in more than 10 sec or it hasn’t caught up to recent messages in 10 sec
148
What is the purpose of a Kafka broker?
storing, managing, and distributing messages by receiving data from producers, storing it across partitions within topics, and serving that data to consumers when requested
149
How do you access a web application running in a Docker container from a browser?
docker run –p
150
How can you run a Docker container in detached mode?
docker run -d
151
What does the 'docker pull' command do?
downloads a Docker image from a registry (typically Docker Hub) to your local machine
152
How can you remove a Docker image?
docker rmi
153
What is the purpose of Docker Swarm
allows users to manage a cluster of Docker hosts as a single system
154
How can you specify a working directory for a command in a Dockerfile
WORKDIR
155
What does the EXPOSE instruction in a Dockerfile do?
informs Docker that the container listens on specific ports at runtime
156
What is the main difference between a Docker container and a virtual machine?
Virtual Machines virtualize underlying hardware * The sharing and managing of hardware allows for multiple environments (guest OS) to exist on same physical machine * Containers allow OS level virtualization * A logical packaging mechanism in which applications can be abstracted from the environments in which they run * Containers run the same way on any platform Unlike Virtual Machines (VMs), containers do not bundle a full operating system
157
How can you specify the base image for a Dockerfile?
use the "FROM" directive at the very beginning of the Dockerfile, followed by the name of the desired base image (including any tag or version
158
What is the 'docker ps' command used for?
lists all running containers in the Docker engine
159
In Docker, what does the 'docker logs' command do?
shows information logged by a running container
160
What is the main benefit of containerizing a web application?
Portability
161
What is a Docker image?
a blueprint to create container. – An immutable file - a snapshot of a container. – Analogy: AMI for EC2 instance * A package format that includes your application and all its dependencies and runtime information required to run it * Docker images are created with the docker build command * You create containers from docker images by running docker run command * Essentially, containers are running instances of Docker images
162
What is Docker Hub?
used to publish/store and share images
163
How can you forward a port from the Docker host to a Docker container?
-p
164
How can you start a Docker container that was previously stopped?
docker restart and docker start
165
How can you specify multiple commands in a Dockerfile?
&&
166
How can you specify environment variables for a Docker container?
-e or --env flag with the docker run command
167
How can you inspect the metadata of a Docker container?
docker inspect
168
How can you keep data across multiple runs of a Docker container?
Docker volumes
169
How can you run a Docker container in the background and print the container ID
use the --detach or -d for short
170
How can you stop a running Docker container?
docker stop
171
How can you run a command in a running Docker container?
docker exec
172
How can you specify a command to be run when a Docker container starts?
[COMMAND] and [ARG...]
173
Docker Desktop
a GUI on top of Docker Engine. – An easy way to get started with docker, especially on Mac and Windows – Docker Desktop includes Docker Engine, Docker CLI client, Docker Compose, etc. Docker Desktop uses Docker Engine at its core.
174
How do you create an image?
To create a docker image, you define a Dockerfile, which is an input file to create a container image * Dockerfile is a text document that contains all the commands/instructions to assemble an image from your codebase
175
What is a Docker container?
The container technology helps you packages code (e.g., your application) with all its dependencies in a format that can be deployed consistently across the platform * This makes such applications easily portable between machines. * Enables flexibility and portability on where the application can run, * exactly the same whether on prem, cloud, VMs, laptops, or bare metal
176
How can you copy files from your Docker host to a Docker container?
docker cp
177
In Docker, what does the 'docker run' command do?
- create a container from the image using docker utility / runs a command in a new container, pulling the image if needed and starting the container
178
In Docker, what does the 'docker push' command do?
share your images to the Docker Hub registry or to a self-hosted one
179
three phases of containerization
Build - build a container image using docker utility (docker build) – Run - create a container from the image using docker utility (docker run) – Orchestrate - manage lifecycle of containers using a container orchestration platform, such as Kubernetes
180
What does a Pod in Kubernetes represent?
The smallest and simplest unit in the kubernetes object model that you create or deploy
181
What does 'Ingress' in Kubernetes do?
an api object that manages external access to the services in a cluster
182
What is the primary purpose of 'kubectl apply' in Kubernetes?
to create or update resources
183
What does 'kube-proxy' do in Kubernetes?
it maintains network rules on nodes which allow network communication to your pods from network sessions inside or outside of your cluster
184
What is a deployment in Kubernetes?
A Kubernetes API object that manages a replicated application
185
In Kubernetes, what is the role of the ReplicaSet?
to maintain a stable set of replica Pods running at any given time
186
what does a node in kubernetes represent?
a worker macine in kubernetes, a virtual machine or physical machine depending on the cluster, each node is managed by the Master/ A physical or virtual machine running Kubernetes master and worker processes – master node(s) and worker nodes – Worker nodes are where pods are scheduled/hosted * Kubelet and Kubeproxy are the applications that runs on worker nodes and that communicates with the master node.
187
What is the primary responsibility of a container orchestration system?
Automation the deployment, scaling, and management of containerized applications
188
What is 'kube-apiserver' in Kubernetes?
it is the fronted of the kubernetes control plane
189
What is one of the main features that distinguishes Kubernetes from other container orchestrators?
Auto-scaling of applications
190
How do you roll out an update in Kubernetes?
kubectly rollout update
191
In Kubernetes, what is the function of the 'kube-scheduler'?
it controls where pods run based on resource availability
192
What is the role of kube-scheduler in a Kubernetes cluster?
it selects a node for the pod to run on
193
What is 'kubelet' in Kubernetes?
it is an agent that runs on each node in the cluster
194
How do you typically update a deployment in Kubernetes?
kubectl apply -f FILENAME
195
What is the primary purpose of 'kubectl apply' in Kubernetes?
to retrieve the status of resources
196
Which Kubernetes object is used to declare the desired state in which one or more replica instances of a Pod should be running?
Deployment
197
What is Kubernetes?
Kubernetes is an open-source container orchestration system for automating deployment, scaling, and management of containerized applications Kubernetes automatically reboots pods in case of failures/crash. * Kubernetes also support rolling updates.
198
Kubernetes Cluster
A collection of physical or virtual machines working together
199
Kubernetes Service
A reliable networking endpoint for a pod or a set of pods with same configuration – A service handles incoming requests, * either coming from inside the Kubernetes cluster, from one node to another or from outside the cluster, and routes them to relevant pods hosting your application. – Service Types: ClusterIP, NodePort, Load Balancer * Services are essentially definition of how requests should be routed and handled within the cluster.